在控制台中看不到Windows程序的标准输出(与Windows上的Clang一起编译) [英] Can't see Windows program's stdout in console (compiled with Clang on Windows)
本文介绍了在控制台中看不到Windows程序的标准输出(与Windows上的Clang一起编译)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用clang构建一个简单的控制台应用程序时,它可以正常工作:
When I build a simple console app with clang, it works fine:
void main(){puts( HELLO); }
但是当我使用 WinMain
创建Windows应用程序时,
But when I create a Windows app with WinMain
, I can't see stdout.
必须有一个修复它的标志,例如MinGW的 -mconsole
There must be a flag that fixes it, like MinGW's -mconsole
推荐答案
其他GUI应用程序的快速stdout-enabler:
A quick stdout-enabler for otherwise GUI apps:
if (AllocConsole())
{
FILE* fi = 0;
freopen_s(&fi, "CONOUT$", "w", stdout);
}
,然后 std :: cout
和 printf
工作。
这篇关于在控制台中看不到Windows程序的标准输出(与Windows上的Clang一起编译)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文