windows平台,wxWidget控制台输出问题。
wxWidget的命令行被封装了一层,默认没有继承父进程的输出。从命令行启动时,cout和printf是没有输出的。如果想要输出,需要自己绑定一下
// Bind func.
void AttachParentConsole() {
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
FILE* fp;
freopen_s(&fp, "CONOUT$", "w", stdout);
freopen_s(&fp, "CONOUT$", "w", stderr);
freopen_s(&fp, "CONIN$", "r", stdin);
}
}
bool MyApp::OnInit() {
#ifdef _WIN32
AttachParentConsole();
#endif
// ...
}