我已经苦恼了一个小时,希望能得到一些帮助。 我想使用 compile_commands.json
文件和vs code以及cpp扩展程序。以下是我的c_cpp_properties.json
文件和compile_commands.json
文件。
c_cpp_properties.json
...
{
"name": "Win32",
"intelliSenseMode": "clang-x64",
"includePath": [
"${workspaceRoot}",
"C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++",
"C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/mingw32",
"C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/backward",
"C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include",
"C:/MinGW/mingw64/include",
"C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include-fixed"
],
"defines": [
"_DEBUG",
"UNICODE",
"__GNUC__=6",
"__cdecl=__attribute__((__cdecl__))"
],
"compileCommands": "${workspaceFolder}/BlitzEngine/builds/Debug/compile_commands.json",
"browse": {
"path": [
"C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include",
"C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include-fixed",
"C:/MinGW/mingw64/include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
...
compile_commands.json
[
{
"directory": "C:/Users/Emburn/Documents/Projects/BlitzEngine/builds/Debug",
"command": "C:\\MinGW\\mingw64\\bin\\g++.exe @CMakeFiles/BlitzEngine.dir/includes_CXX.rsp -g -o CMakeFiles\\BlitzEngine.dir\\src\\BlitzEngine.cpp.obj -c C:\\Users\\Emburn\\Documents\\Projects\\BlitzEngine\\src\\BlitzEngine.cpp",
"file": "C:/Users/Emburn/Documents/Projects/BlitzEngine/src/BlitzEngine.cpp"
},
{
"directory": "C:/Users/Emburn/Documents/Projects/BlitzEngine/builds/Debug",
"command": "C:\\MinGW\\mingw64\\bin\\g++.exe @CMakeFiles/BlitzEngine.dir/includes_CXX.rsp -g -o CMakeFiles\\BlitzEngine.dir\\src\\main.cpp.obj -c C:\\Users\\Emburn\\Documents\\Projects\\BlitzEngine\\src\\main.cpp",
"file": "C:/Users/Emburn/Documents/Projects/BlitzEngine/src/main.cpp"
},
{
"directory": "C:/Users/Emburn/Documents/Projects/BlitzEngine/builds/Debug",
"command": "C:\\MinGW\\mingw64\\bin\\g++.exe @CMakeFiles/BlitzEngine.dir/includes_CXX.rsp -g -o CMakeFiles\\BlitzEngine.dir\\src\\RenderWindow.cpp.obj -c C:\\Users\\Emburn\\Documents\\Projects\\BlitzEngine\\src\\RenderWindow.cpp",
"file": "C:/Users/Emburn/Documents/Projects/BlitzEngine/src/RenderWindow.cpp"
}
]
我尝试使用绝对路径而没有使用${workspaceFolder}
,但是这也不起作用,每次保存文件时都会出现以下提示:
"${workspaceFolder}/BlitzEngine/builds/Debug/compile_commands.json"
could not be found. Using 'includePath'
setting in c_cpp_properties.json
我的目录树如下:
Projects
+-- .vscode
| +-- c_cpp_properties.json
+-- BlitzEngine
| +-- Debug
| | +-- compile_commands.json
+-- include
| +-- <header_files>
+-- src
| +-- <source_files>
感谢您提前提供的任何帮助!
compile_commands.json
的标准做法是使用工具(如cmake
)为您生成它。 - Stephen NewellworkspaceFolder
而不是workspaceRoot
。 - Stephen NewellworkspaceRoot
实际上已经被弃用了。建议改用workspaceFolder
。 - Julia