只需要在main函数里面添加一句代码,再重新编译运行就好
// 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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。