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

Discussion in 'C++' started by MuZZy, Jan 7, 2005.

  1. MuZZy

    MuZZy Guest

    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
    MuZZy, Jan 7, 2005
    #1
    1. Advertising

  2. Re: Console profile for Windows app in VC++ - PLEASE PLEASE PLEASEHELP!

    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
    Victor Bazarov, Jan 7, 2005
    #2
    1. Advertising

  3. MuZZy

    MuZZy Guest

    Re: Console profile for Windows app in VC++ - PLEASE PLEASE PLEASEHELP!

    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
    MuZZy, Jan 7, 2005
    #3
  4. Re: Console profile for Windows app in VC++ - PLEASE PLEASE PLEASEHELP!

    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
    Victor Bazarov, Jan 7, 2005
    #4
  5. MuZZy

    MuZZy Guest

    Re: Console profile for Windows app in VC++ - PLEASE PLEASE PLEASEHELP!

    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...
    MuZZy, Jan 7, 2005
    #5
  6. Re: Console profile for Windows app in VC++ - PLEASE PLEASE PLEASEHELP!

    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.
    Victor Bazarov, Jan 7, 2005
    #6
  7. MuZZy

    MuZZy Guest

    Re: Console profile for Windows app in VC++ - PLEASE PLEASE PLEASEHELP!

    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
    MuZZy, Jan 7, 2005
    #7
  8. MuZZy

    Mike Hewson Guest

    Re: Console profile for Windows app in VC++ - PLEASE PLEASE PLEASEHELP!

    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
    Mike Hewson, Jan 7, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brad
    Replies:
    1
    Views:
    1,127
    Roedy Green
    Jul 19, 2005
  2. pkellner
    Replies:
    0
    Views:
    492
    pkellner
    Apr 27, 2007
  3. Andy B
    Replies:
    0
    Views:
    511
    Andy B
    May 3, 2008
  4. Steven
    Replies:
    5
    Views:
    469
    Steven
    Oct 24, 2008
  5. Kris Rudin

    console app w/o seeing console?

    Kris Rudin, Nov 11, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    122
    Randy Charles Morin
    Nov 11, 2003
Loading...

Share This Page