开发者

WINDOWS.H already included error

I get an error when trying to compile a small c++ program

Error 87 fatal error C1189: #error : WINDOWS.H already included开发者_开发百科. MFC apps must not #include c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxv_w32.h 16

I made sure that the windows.h was not included in any of the project files I have. I am using a visual studio 2008 IDE

Any reason why ?


reason why is because something is including Windows.h: the compiler is not lying to you.

Go to project Properties->Configuration Properties->C/C++->Advanced and set Show Includes to Yes. Then build, and the compiler will show you a list with every included file found, and in the order it finds it, hereby telling you which file eventually includes windows.h


try and include afxcoll.h before stdafx.h. I had the same problem and it fixed it. See http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/2ab6862f-0d90-467a-b283-f62f6aef96fe/ for the original discussion.


#include "afxwin.h"         // MFC core and standard components
#include "afxext.h"         // MFC extensions

Adding these to my stdafx.h file sorted out that error..hope this helps someone else.


Visual Studio by default will defile your program with a precompiled headers file, which may contain something which includes something which includes windows.h . Be sure to check in there.


In your project go to Configuration Properties->C/C++ -> Precompiled Headers. Make sure the Precompiled Header setting is set to Use(/Yu).

This setting "Enables creation or use of a precompiled header during the build".


The problem I had was the "stdafx.h" file is being included in the "StdAfx.h" file, and the file name in Configuration Properties->C/C++ ->Precompiled Headers was never updated from "stdafx.h" to "StdAfx.h".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜