VS项目中非stdafx.h文件目录包含stdafx.h的编译失败的解决方法
来源:互联网 发布:淘宝分期买手机可靠吗 编辑:程序博客网 时间:2024/04/28 05:50
如果stdafx.h和你当前的工程不在一个文件夹下,当你在代码中第一行写下#include "stdafx.h"时,vc编译器会根据编译规则(相关的规则请查看msdn)来区别stdafx.h的位
置,但是其智能感知工具intellisense却不能。所以你的代码即使能够通过编译器,而intellisense却不能感知到,因为它没有利用相同的规则。如果你指定了这个文件的
具体位置,例如"..//stdafx.h",此时intellisene能够正确的感知到,而编译器却找不到,并给出一个错误。因为编译器只认识这样的预定义头文件字符:#include
"stdafx.h"。
为什么会有如此糟糕的结果呢?微软宣称这是经过精心考虑后设计的。(http://connect.microsoft.com/visualstudio/feedback/details/533605/stdafx-h-cant-be-
parsed-with-intellisense-squiggles-mechanism[^]).
有很多方法绕过编译器的这个“特色”。一般地,你可以用如下形式来分别满足编译器和intellisense,
#include "stdafx.h" //pre-compiled header for compiler
#include "..//stdafx.h" //exact location of pre-compiled header for intellisense
或者,你也可以通过project->properties->configuration propertes->c/c++->general->additional include directories,添
加"$(projectdir)",作为默认目录。一般的,如果工程非常大的话,建议你采用这种方法。
置,但是其智能感知工具intellisense却不能。所以你的代码即使能够通过编译器,而intellisense却不能感知到,因为它没有利用相同的规则。如果你指定了这个文件的
具体位置,例如"..//stdafx.h",此时intellisene能够正确的感知到,而编译器却找不到,并给出一个错误。因为编译器只认识这样的预定义头文件字符:#include
"stdafx.h"。
为什么会有如此糟糕的结果呢?微软宣称这是经过精心考虑后设计的。(http://connect.microsoft.com/visualstudio/feedback/details/533605/stdafx-h-cant-be-
parsed-with-intellisense-squiggles-mechanism[^]).
有很多方法绕过编译器的这个“特色”。一般地,你可以用如下形式来分别满足编译器和intellisense,
#include "stdafx.h" //pre-compiled header for compiler
#include "..//stdafx.h" //exact location of pre-compiled header for intellisense
或者,你也可以通过project->properties->configuration propertes->c/c++->general->additional include directories,添
加"$(projectdir)",作为默认目录。一般的,如果工程非常大的话,建议你采用这种方法。
0 0
- VS项目中非stdafx.h文件目录包含stdafx.h的编译失败的解决方法
- VS工程中如何在其它目录下的文件中包含stdafx.h的问题
- stdafx.h文件的作用
- stdafx.h 文件的作用
- stdafx.h 包含的头文件出错,导致大问题.
- stdafx.h 在VS环境中的文件的作用
- stdafx.h的作用
- stdafx.h 的作用
- stdafx.h的作用
- stdafx.h的作用
- stdafx.h的作用
- stdafx.h的作用
- stdafx.h的作用
- stdafx.h的作用
- stdafx.h的作用
- stdafx.h的作用
- stdafx.h的作用
- stdafx.h的作用
- L1-037. A除以B
- leetcode上令人拍案叫绝的解法
- redis系列(七)redis集群
- 第五周报告
- leetcode 77
- VS项目中非stdafx.h文件目录包含stdafx.h的编译失败的解决方法
- Codevs 3322 时空跳跃者的困境(组合数 二项式定理)
- Docker国内镜像源设置
- 分蛋糕
- 记录学习的点滴(Java内存泄漏)
- 嵌入式文本编辑器(vi)
- tensorflow 注意事项
- JVM GC算法以及调优
- linux内存管理(一)