920167075 发表于 2013-12-4 05:50:46

C++编译出现的问题。非常有效果。

e:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :WINDOWS.H already included.MFC apps must not #include <windows.h>
Error executing cl.exe.

想用CFileFind类,因此#include <afx.h>就编译不过了,网上说要把#include <windows.h>删掉,那我的vc工程里有很多文件都包含了这句,都要注释掉吗?有没有其它方法啊。
另外为什么不包含#include <afx.h>可以编译过呢?
请哪位大侠指点一下!!多谢多谢!!




1#
编译器提示你了
MFC apps must not #include <windows.h>
两者不能同时      


2#
多谢!!楼上的意思是要把#include <windows.h>删掉?我的许多文件都有这句,那改动就很大了,还有其它的方法没?


3#
替换一下吧。在stdafx.h里面包含#include <afxwin.h>,然后把所有其它文件的#include <windows.h>注释掉      


4#
就是说你不能同时包含afxwin.h 和windows.h      


5#
这个很简单,你首先要在适当的地方
#undef windows.h的特殊标志,然后再#include windows.h就可以了。


6#

1
2
3
4
#ifdef _WINDOWS_
#undef _WINDOWS_
#include "afxcmn.h"
#endif



比如这种做法。


7#
有次序要求的,将这个多换几个地方就可以了。


8#

...


9#
..


10#
我也遇到过相同的问题,可能是#include <afx.h>的位置放得不对,在每一个.cpp或.h里面都应该是第一行。

感谢。。。我也遇到过这种情况,重于找到了答案。。。。
转自http://bbs.csdn.net/topics/300172109

邪龙之影 发表于 2013-12-18 10:33:07

悄悄的我走了,正如我悄悄的来,挥一挥匕首,不留一个活口。
页: [1]
查看完整版本: C++编译出现的问题。非常有效果。