其中起作用的就是这几句了
- // uncomment below line,open debug console
- #define USE_WIN32_CONSOLE
- int WINAPI _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow)
- {
- UNREFERENCED_PARAMETER(hPrevInstance);
- UNREFERENCED_PARAMETER(lpCmdLine);
- #ifdef USE_WIN32_CONSOLE
- AllocConsole();
- freopen("CONIN$","r",stdin);
- freopen("CONOUT$","w",stdout);
- freopen("CONOUT$",stderr);
- #endif
- auto simulator = SimulatorWin::getInstance();
- int ret = simulator->run();
- #ifdef USE_WIN32_CONSOLE
- FreeConsole();
- #endif
- return ret;
- }
- #ifdef USE_WIN32_CONSOLE
- AllocConsole();
- freopen("CONIN$",stderr);
- #endif
- #ifdef USE_WIN32_CONSOLE
- FreeConsole();
- #endif
这个宏定义就是开关
- // uncomment below line,open debug console
- #define USE_WIN32_CONSOLE
当然,新版里面有一个SimulatorWin.cpp 文件,这个文件里面定义了一个宏
- #define SIMULATOR_WITH_CONSOLE_AND_MENU 0
这个宏要是等于0,那么就不会显示控制台输出,只要将这个宏的值改为 0 以上的数,控制台就完美的显示出来了
将上面宏的值换成下面这个
- #define SIMULATOR_WITH_CONSOLE_AND_MENU 1
因为在这个文件的 248 行有这么一个判断
- #if (SIMULATOR_WITH_CONSOLE_AND_MENU > 0)
- // create console window
- if (_project.isShowConsole())
- {
- AllocConsole();
- _hwndConsole = GetConsoleWindow();
- if (_hwndConsole != NULL)
- {
- ShowWindow(_hwndConsole,SW_SHOW);
- BringWindowToTop(_hwndConsole);
- freopen("CONOUT$","wt",stdout);
- freopen("CONOUT$",stderr);
- HMENU hmenu = GetSystemMenu(_hwndConsole,FALSE);
- if (hmenu != NULL)
- {
- DeleteMenu(hmenu,SC_CLOSE,MF_BYCOMMAND);
- }
- }
- }
- #endif