開始使用vscode,便被添加頭文件路徑給擋住了。
在使用第三方庫如boost的時候,應該在tasks.json和c_cpp_properties.json分別添加頭文件路徑。
因為vscode的編輯器和編譯器分別是兩套獨立的系統,這跟visual studio是不同的。
主要原因是沒有在tasks.json中指定路徑。
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build with mingw-64",
"command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"--std=c++17",
"-ID:\\work\\00Tools\\boost\\include\\",
"-o",
"${fileDirname}\\simple.exe"
],
"options": {
"cwd": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: \"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe\""
}
]
}
在c_cpp_properties中添加路徑,可以實現單擊頭文件時可以跳轉。
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"D:\\work\\00Tools\\boost\\include\\**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
