今天程序出现如下一个问题
fatal error C1020: 意外的 #endif
代码如下:
#ifndef TIXML_USE_STL #include “stdafx.h”
。。。(中间代码省略)
#endif
在网上查找错误原因,找到如下帖子
http://topic.csdn.net/u/20070810/09/f8381d20-10b4-4b08-8549-eaa70ceeb16a.html
原因拷贝如下:
如果使用了预编译头…那么VC会在所有CPP文件里寻找 #include “stdafx.h “ 在找到这行代码之前 VC忽略所有代码… 所以说.. 在.cpp文件中 动态调整包含stdafx.h 是不可能的事情.. #ifdef _MFC_ #include “stdafx.h “ #endif #ifdef _MFC_直接被忽略…所以 endif有问题…. 解决办法 不使用预编译头, 当然你的想法也实现不了..
-———————
我的解决办法如下: 把 #include “stdafx.h” 放到第一行。 然后问题解决。
#include “stdafx.h”
#ifndef TIXML_USE_STL
。。。(中间代码省略)
#endif
- 本文作者: royalchen
- 本文链接: http://www.royalchen.com/2016/02/24/fatalerrorc1020意外的endif/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!