![](/img/trans.png)
[英](C/C++, Windows) Issues with AttachConsole and FreeConsole only working once
[英]C++ AttachConsole include error
我如何包含AttachConsole? 我总是得到“未在此范围内声明”错误。
我发现这个“要编译使用此函数的应用程序,请将_WIN32_WINNT定义为0x0501或更高版本。有关更多信息,请参阅使用Windows标头。” 在Microsoft MSDN 网站上 ,但无法正常工作。
#include <iostream>
#include <stdio.h>
#include <windows.h>
#define _WIN32_WINNT 0x0502
int main() {
AttachConsole(8336);
}
当然,您需要将_WIN32_WINNT
定义为> = 0x0501,但在包含Windows标头之前需要这样做,否则它将无效。
改为:
#include <iostream>
#include <stdio.h>
#define _WIN32_WINNT 0x0502
#include <windows.h>
int main() {
AttachConsole(8336);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.