intelliSense:无法打开源文件 'example.h'
intelliSense: cannot open source file 'example.h'
我有一个问题,我无法让 VS 打开我的头文件,尽管我已经将它添加到我项目的头文件中
IntelliSense:无法打开源文件"globals.h"
#include "globals.h"
在 VS(2008 及更新版本)中:
#include "path-spec"
The path-spec is a file name optionally preceded by a directory specification. The file name must name an existing file. The syntax of the path-spec depends on the operating system on which the program is compiled.
The preprocessor searches for include files in the following order:
- In the same directory as the file that contains the #include statement.
- In the directories of any previously opened include files in the reverse order in which they were opened. The search starts from the directory of the include file that was opened last and continues through the directory of the include file that was opened first.
- Along the path specified by each /I compiler option.
- Along the paths specified by the INCLUDE environment variable.
预处理器在找到具有给定名称的文件后立即停止搜索。如果在双引号 (" ") 之间为包含文件指定完整、明确的路径规范,则预处理器仅搜索该路径规范并忽略标准目录。
如果双引号中的文件名是不完整的路径说明,预处理器首先搜索"parent" 文件的目录。父文件是包含 #include
指令的文件。例如,如果您在名为 file1
的文件中包含一个名为 file2
的文件,则 file1
是父文件。
如果您的项目中包含带有头文件的文件夹,则可以在 VS 中使用以下语法:
#include "foldername\headerfile.h"
我有一个问题,我无法让 VS 打开我的头文件,尽管我已经将它添加到我项目的头文件中
IntelliSense:无法打开源文件"globals.h"
#include "globals.h"
在 VS(2008 及更新版本)中:
#include "path-spec"
The path-spec is a file name optionally preceded by a directory specification. The file name must name an existing file. The syntax of the path-spec depends on the operating system on which the program is compiled.
The preprocessor searches for include files in the following order:
- In the same directory as the file that contains the #include statement.
- In the directories of any previously opened include files in the reverse order in which they were opened. The search starts from the directory of the include file that was opened last and continues through the directory of the include file that was opened first.
- Along the path specified by each /I compiler option.
- Along the paths specified by the INCLUDE environment variable.
预处理器在找到具有给定名称的文件后立即停止搜索。如果在双引号 (" ") 之间为包含文件指定完整、明确的路径规范,则预处理器仅搜索该路径规范并忽略标准目录。
如果双引号中的文件名是不完整的路径说明,预处理器首先搜索"parent" 文件的目录。父文件是包含
#include
指令的文件。例如,如果您在名为file1
的文件中包含一个名为file2
的文件,则file1
是父文件。
如果您的项目中包含带有头文件的文件夹,则可以在 VS 中使用以下语法:
#include "foldername\headerfile.h"