我刚开始学习如何编程。我在我的Mac和C/C++扩展上设置了VSCode。我从Stroustrup的编程和原则书中编写了helloworld程序。我将std_lib_facilities.h文件放在与helloworld.cpp文件相同的文件夹中。不过,我还是得到了错误消息:#include错误检测到了。请更新您的includePath。此翻译单元禁用Squiggles。
为什么我还会有这个错误?书中说,我所需要的只是将std_lib_facilities.h.txt文件与我的.cpp程序放在同一个目录中。它们在同一个文件夹中,为什么我会收到这个错误呢?
我的代码:
#include "std_lib_facilites.h"
int main()
{
cout << "Hello World \n";
return 0;
}发布于 2020-04-11 12:59:13
首先,文件名中有一个错误。
#include "std_lib_facilites.h"
应该是std_lib_facilities.h (来源1,来源2)。
并确保将其保存为.h。
其次,您可以配置一个. .vscode/c_cpp_properties.json ties.json文件来指定头文件的路径。请参阅JSON模式引用的VS代码文档。
includePath "configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/path/to/headers"
],
...
}
],默认情况下,它已经有了"${workspaceFolder}/**",它应该在您的工作区(和它的子文件夹)中搜索头文件。但也可以指定其他文件夹的路径。
https://stackoverflow.com/questions/61156790
复制相似问题