我正在使用 vscode 进行测试,看看它在 c 中编辑代码的能力。我在配置标头路径时遇到问题,为了方便标头导入,因为我将它们放在单独的文件夹中进行组织,我配置了 Microsoft C/C++ 扩展以将 include 文件夹添加为标头的路径,但是似乎没有去上班
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c23",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-x64",
"browse": {
"path": [
"${workspaceFolder}/include",
"${workspaceFolder}/src"
],
"limitSymbolsToIncludedHeaders": false,
"databaseFilename": ""
}
}
],
"version": 4
}
这是创建的c_cpp_properties文件,但它似乎没有做任何事情。
我仍然收到此错误:
Iniciando o build...
/usr/bin/gcc -fdiagnostics-color=always -g /home/user/Codes/C/TestProject/src/*.c -o /home/user/Codes/C/TestProject/src/../output/Main
/home/user/Codes/C/TestProject/src/Main.c:2:10: fatal error: List.h: No such file or directory
2 | #include "List.h"
| ^~~~~~~~
compilation terminated.
Build concluída com erro(s).
将路径添加到您的 .json 文件
"includePath": ["${myDefaultIncludePath}", "/another/path"],