Console profile for Windows app in VC++ - PLEASE PLEASE PLEASE HELP!

M

MuZZy

HI

I just wonder if someone can help me with this:
I have a windows app project developed on VC++ 6.0.
I need to adapt it to be able to compile as a console app as well
(So it would call main() instead of WinMain())

I created a new profile for the project and replaced precompile define _WINDOWS by _CONSOLE,
and changed linker option /subsystem:windows to /subsystem:console.

I also added a condidtional main():
#ifdef _CONSOLE
int main() {...}
#else
int PASCAL WinMain
(
HINSTANCE hinst,
HINSTANCE hinstPrev,
LPSTR pszCmdLine,
int nCmdShow
)
#endif

It compiles fine with both "Debug" and my new "Console Debug" profiles. In first case it starts then
as a Windows app, in second it shows a console. So no problem here.

But, problems come when i try to add some functionality to main(). First if i add those includes,
it doesn't compile, saying that "__cplusplus" is not defined.

#ifdef _CONSOLE
#include <iostream>
#include <ostream> //to use cout
#endif

If i also define __cplusplus, it starts giving hell of other errors in standard c++ headers
like errno.h, stdio.h, etc...


But, if i create a brand new console project and copy all my files there, it compiles and works fine...
So i assume that i still didn't change something in the "Console Debug" profile to work correctly...


Any ideas?

Thank you in advance,
Andrey







If i compile with this new profile
 
V

Victor Bazarov

MuZZy said:
I just wonder if someone can help me with this:
I have a windows app project developed on VC++ 6.0.
I need to adapt it to be able to compile as a console app as well
(So it would call main() instead of WinMain())

I created a new profile for the project and replaced precompile define
_WINDOWS by _CONSOLE,
and changed linker option /subsystem:windows to /subsystem:console.

I also added a condidtional main():
#ifdef _CONSOLE
int main() {...}
#else
int PASCAL WinMain
(
HINSTANCE hinst,
HINSTANCE hinstPrev,
LPSTR pszCmdLine,
int nCmdShow
)
#endif

It compiles fine with both "Debug" and my new "Console Debug" profiles.
In first case it starts then
as a Windows app, in second it shows a console. So no problem here.

But, problems come when i try to add some functionality to main(). First
if i add those includes,
it doesn't compile, saying that "__cplusplus" is not defined.

It is usually the case when you have the file with .c extension. Rename
your file or tell your compiler to compile it as a C++ file (RTFM on the
compiler switches).

And this is not the right newsgroup. Please consider posting to
microsoft.public.vc.ide_general or microsoft.public.vc.project_mgt

V
 
M

MuZZy

Victor said:
It is usually the case when you have the file with .c extension. Rename
your file or tell your compiler to compile it as a C++ file (RTFM on the
compiler switches).

Thank you, i will try. It's true that my src files have .c extension

BTW, what is RTFM?
I didn't find in settings where to explicitly tell the compiler to treat those files as c++.
And this is not the right newsgroup. Please consider posting to
microsoft.public.vc.ide_general or microsoft.public.vc.project_mgt
Will do!

Andrey
 
M

MuZZy

Victor said:
MuZZy said:
[...]
BTW, what is RTFM?


Strange to read it from you given that you know 'BTW'.

Well, maybe that's because when THEY ask ME a question i try to help instead of reffering to
"Read The F*** Manual"...
You will, eventually.
Good answer... Do you just NOT remember/know or you're trying to be sarcastic?
Well, beleive or not, i walked thru all the profile settings and didn't find it..

Ah... whatever...
 
V

Victor Bazarov

MuZZy said:
Victor said:
MuZZy said:
[...]
BTW, what is RTFM?



Strange to read it from you given that you know 'BTW'.


Well, maybe that's because when THEY ask ME a question i try to help
instead of reffering to
"Read The F*** Manual"...

I tried to help. Posting the precise answer here would be off-topic.

I answered your question in another newsgroup. Sorry I bothered at all.
Next time I probably won't.
 
M

MuZZy

Victor said:
MuZZy said:
Victor said:
MuZZy wrote:

[...]
BTW, what is RTFM?




Strange to read it from you given that you know 'BTW'.



Well, maybe that's because when THEY ask ME a question i try to help
instead of reffering to
"Read The F*** Manual"...


I tried to help. Posting the precise answer here would be off-topic.

I answered your question in another newsgroup.

I've seen it, And i do appreciate it!
But i just don't understand when people are playing like that..
Well, i guess it's the problem with my mentality...
I guess i got a "News Group Offensing" way of thinking... :))
Sorry I bothered at all.
Next time I probably won't.

Again, i appreciate your help.. and i didn't wnat to offense you...
I just don't appreciate sarcastic answers..
well maybe that's because i don't do it myself
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top