#error WINDOWS.H already included. MFC apps must not #include <windows.h>
Solution 1
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
Solution 2
Change the include order, and include afx < headers > before the others
Solution 3
First, see what translation unit (cpp file) was compiled when the error occured (see build log).
Then... you could either inspect the header files included by that cpp file, looking for <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.
Solution 4
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.
Related videos on Youtube
Comments
-
Uday almost 4 years
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
Thanks
-
EFraim almost 8 years@CyprUS: stdafx.h is not a Windows file. It's yours.
-
Gustavo Grisales about 2 yearsthis solution works for me