switching between console and non console apps

Started by
4 comments, last by Oluseyi 17 years, 4 months ago
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=)
Advertisement
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
"I'd rather know one thing, no matter how ordinary, than discourse endlessly on great issues." -- Galileo
BAH forgot to add windows.h like a fool lol. thx anyways guys.
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 =)
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...
"I'd rather know one thing, no matter how ordinary, than discourse endlessly on great issues." -- Galileo
Did you forget to include windows.h?

You can also make the compile conditional:
...#ifdef _DEBUGint main(...)#elseint 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.

This topic is closed to new replies.

Advertisement