Sign in to follow this  
jchmack

switching between console and non console apps

Recommended Posts

jchmack    187
hi im trying to make an application that i can have a console i can turn on during debug and turn off when i want to give it to my friends and just run it. im trying to have to main functions like this: int main(int argc, char *argv[]) { app.run(); return 0; } int WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT ) { app.run(); return 0; } and just comment out the one im not using at the moment. so i made a win32 console app and ran the first main and it worked fine. But then i went to Project Properties->Linker->System->Subsytem and changed that from console to windows. Then i commented out the first main and am now just using the second. I get these errors: 1>------ Build started: Project: game4, Configuration: Debug Win32 ------ 1>Compiling... 1>Program Entry.cpp 1>c:\documents and settings\julius abella\desktop\game4\game4\game4\program entry.cpp(23) : error C2146: syntax error : missing ';' before identifier 'WinMain' 1>c:\documents and settings\julius abella\desktop\game4\game4\game4\program entry.cpp(23) : error C2065: 'HINSTANCE' : undeclared identifier 1>c:\documents and settings\julius abella\desktop\game4\game4\game4\program entry.cpp(23) : error C2146: syntax error : missing ')' before identifier 'hInst' 1>c:\documents and settings\julius abella\desktop\game4\game4\game4\program entry.cpp(23) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\documents and settings\julius abella\desktop\game4\game4\game4\program entry.cpp(23) : error C2059: syntax error : ')' 1>c:\documents and settings\julius abella\desktop\game4\game4\game4\program entry.cpp(24) : error C2143: syntax error : missing ';' before '{' 1>c:\documents and settings\julius abella\desktop\game4\game4\game4\program entry.cpp(24) : error C2447: '{' : missing function header (old-style formal list?) 1>Build log was saved at "file://c:\Documents and Settings\Julius Abella\Desktop\game4\game4\game4\Debug\BuildLog.htm" 1>game4 - 7 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Shouldn't this work? shouldn't this just be like starting a new win32 app and just running the second main? Is what im doing practical? or even possible? Thx in advance for all input=)

Share this post


Link to post
Share on other sites
F1N1TY    478
change INT to int nCmdShow
change second HINSTANCE to HINSTANCE prevInstance

ADD:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>

To the top of your file

Share this post


Link to post
Share on other sites
jchmack    187
Quote:
Original post by F1N1TY
change INT to int nCmdShow
change second HINSTANCE to HINSTANCE prevInstance

ADD:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>

To the top of your file


thx man i figured it out as you were posting =)

Share this post


Link to post
Share on other sites
F1N1TY    478
Quote:
Original post by jchmack
Quote:
Original post by F1N1TY
change INT to int nCmdShow
change second HINSTANCE to HINSTANCE prevInstance

ADD:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>

To the top of your file


thx man i figured it out as you were posting =)


Haha, I saw that, just kinda laughed...

Share this post


Link to post
Share on other sites
Oluseyi    2103
Did you forget to include windows.h?

You can also make the compile conditional:

...

#ifdef _DEBUG

int main(...)
#else

int WINAPI WinMain(...)
#endif
{
app.run();
return 0;

}


Then go and set up your subsystems so that it's console for debug configuration and windows for release.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this