C++ #error WINDOWS.H 已包含在内。MFC 应用程序不得 #include <windows.h>
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1017814/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
#error WINDOWS.H already included. MFC apps must not #include <windows.h>
提问by Uday
I am getting #error WINDOWS.H already included. MFC apps must not #include windows.h But i dont know how do i find out because of which file this is happening
我收到#error WINDOWS.H 已经包含在内。MFC 应用程序不能 #include windows.h 但我不知道如何找出发生这种情况的文件
Thanks
谢谢
回答by vim
Change the include order, and include afx < headers > before the others
更改包含顺序,并在其他之前包含 afx < headers >
回答by Alan
Try turning on "Show Includes" in the projects settings (C/C++ -> Advanced). This show give you an indication of what header files are included and in what order - you should be able to trace back from there
尝试在项目设置(C/C++ -> 高级)中打开“显示包含”。该节目为您提供了包含哪些头文件以及包含的顺序的指示 - 您应该能够从那里追溯到
回答by C?t?lin Piti?
First, see what translation unit (cpp file) was compiled when the error occured (see build log).
首先,查看发生错误时编译的翻译单元(cpp 文件)(参见构建日志)。
Then... you could either inspect the header files included by that cpp file, looking for <windows.h>
.
然后...您可以检查该 cpp 文件包含的头文件,寻找<windows.h>
.
You could also search in all project files for to check whether it is included from your code.
您还可以在所有项目文件中搜索以检查它是否包含在您的代码中。
If you're using other 3rd party libraries that include windows.h header, then you might be forced to change the order of inclusion of those header files and MFC headers.
如果您使用包含 windows.h 头文件的其他 3rd 方库,那么您可能被迫更改这些头文件和 MFC 头文件的包含顺序。
回答by Rasmi Ranjan Nayak
Check probably Windows.h
might be included in your stdafx.h
file. If so, then comment Windows.h
and then check, the error may go off. Because I had the same problem I resolve in same way.
检查可能Windows.h
包含在您的stdafx.h
文件中。如果是这样,然后评论Windows.h
然后检查,错误可能会消失。因为我有同样的问题,所以我以同样的方式解决。