我有一个文件是多个程序的公用文件,而另外不是MFC的程序不需要包含stdafx.h头文件.于是我先在我的MFC工程中,预处理器中加入一个宏_MFC_,然后我在.cpp中写:
#ifdef _MFC_
#include "stdafx.h"
#endif结果老是报:
fatal error C1020: 意外的 #endif这个很诡异,如果我去掉#include "stdafx.h",则不会有这个错误
#ifdef _MFC_
//#include "stdafx.h"
#endif成了
fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"”难道是stdafx.h中的#if #endif 没有配好对么?
#ifdef _MFC_
#include "stdafx.h"
#endif结果老是报:
fatal error C1020: 意外的 #endif这个很诡异,如果我去掉#include "stdafx.h",则不会有这个错误
#ifdef _MFC_
//#include "stdafx.h"
#endif成了
fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"”难道是stdafx.h中的#if #endif 没有配好对么?
#include "stdafx.h"
在找到这行代码之前
VC忽略所有代码...所以说..
在.cpp文件中
动态调整包含stdafx.h
是不可能的事情..#ifdef _MFC_
#include "stdafx.h"
#endif
#ifdef _MFC_直接被忽略...所以
endif有问题....解决办法 不使用预编译头,
当然你的想法也实现不了..