Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Console profile for Windows app in VC++ - PLEASE PLEASE PLEASE HELP!

Reply
Thread Tools

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

 
 
MuZZy
Guest
Posts: n/a
 
      01-07-2005
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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      01-07-2005
MuZZy wrote:
> 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
 
Reply With Quote
 
 
 
 
MuZZy
Guest
Posts: n/a
 
      01-07-2005
Victor Bazarov wrote:
> MuZZy wrote:
>
>> 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).


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
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      01-07-2005
MuZZy wrote:
> [...]
> BTW, what is RTFM?


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

> I didn't find in settings where to explicitly tell the compiler to treat
> those files as c++.


You will, eventually.

V
 
Reply With Quote
 
MuZZy
Guest
Posts: n/a
 
      01-07-2005
Victor Bazarov wrote:
> 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 didn't find in settings where to explicitly tell the compiler to
>> treat those files as c++.


> 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...



 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      01-07-2005
MuZZy wrote:
> Victor Bazarov wrote:
>
>> 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. Sorry I bothered at all.
Next time I probably won't.
 
Reply With Quote
 
MuZZy
Guest
Posts: n/a
 
      01-07-2005
Victor Bazarov wrote:
> MuZZy wrote:
>
>> Victor Bazarov wrote:
>>
>>> 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
 
Reply With Quote
 
Mike Hewson
Guest
Posts: n/a
 
      01-07-2005
MuZZy wrote:
> Victor Bazarov wrote:
>>> Well, maybe that's because when THEY ask ME a question i try to help
>>> instead of reffering to
>>> "Read The F*** Manual"...


Ahhh..... Read The Fine Manual.

--

Cheers
--
Hewson::Mike
"This letter is longer than usual because I lack the time to make it
shorter" - Blaise Pascal
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Studio 2008 asp.net web administration>profile: "The profile wasn't created"? Andy B ASP .Net 0 05-03-2008 05:15 PM
Problem with Assembly.LoadFrom with web app, not unit test console type app. pkellner ASP .Net 0 04-27-2007 03:34 PM
Want to profile monitor for Fuji Frontier ICC profile? Lynn Digital Photography 9 09-08-2005 12:17 PM
Java Web Start app icons keep going in user profile not All Users profile Brad Java 1 07-19-2005 02:10 AM
console app w/o seeing console? Kris Rudin ASP .Net Datagrid Control 1 11-11-2003 10:23 PM



Advertisments