I want my program to show the console window if it detects the solution configuration is debug. If it detects release, then the console window should not show up
#include "Window.h"
int main(int argc, char* argv[]) {
Window Game;
#if defined(_DEBUG)
#pragma comment(linker, "/SUBSYSTEM:console /ENTRY:")
Game.run();
#else
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
Game.run();
#endif
}
The source code above doesn't work because:
LNK1146 no argument specified with option '/ENTRY:'
So I want to know how to pass no argument in #pragma comment (or just improve this source code in general)
(using Visual Studio 2023 and C++ 20)
Any help is appreciated!
The /ENTRY
flag for MSVC always has to be followed by :function_name
. So if you want to keep the default, just don't pass /ENTRY
at all for that case:
#include "Window.h"
int main(int argc, char* argv[]) {
Window Game;
#if defined(_DEBUG)
#pragma comment(linker, "/SUBSYSTEM:console")
Game.run();
#else
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
Game.run();
#endif
}