VSCodeのC/C++拡張機能のIntelisenseのInclude Path設定
環境など
- macOS
- VSCode
- 拡張機能: C/C++ (Extension Pack)
- llvm/clang
設定手順
- C/C++設定ファイルを開く
- Cmd+Shift+P、
- 必要な設定を調べる
clang++ -v -E -x c++ -
- Ctrl+Cで終了する。
- 出力されたコマンド引数から必要な引数を抜き出して
includePath
に追加する。
saitama@MacBook-Pro bug-finder % clang++ -v -E -x c++ -
Homebrew clang version 11.1.0
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm@11/bin
(in-process)
"/usr/local/Cellar/llvm@11/11.1.0_4/bin/clang-11" -cc1 -triple x86_64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-rounding-math -munwind-tables -fcompatibility-qualified-id-block-type-checking -target-cpu penryn -debugger-tuning=lldb -target-linker-version 820.1 -v -resource-dir /usr/local/Cellar/llvm@11/11.1.0_4/lib/clang/11.1.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -stdlib=libc++ -internal-isystem /usr/local/opt/llvm@11/bin/../include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/local/include -internal-isystem /usr/local/Cellar/llvm@11/11.1.0_4/lib/clang/11.1.0/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include -fdeprecated-macro -fdebug-compilation-dir /Users/saitama/go/src/github.com/tractrix/bug-finder -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcolor-diagnostics -o - -x c++ -
clang -cc1 version 11.1.0 based upon LLVM 11.1.0 default target x86_64-apple-darwin21.6.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/opt/llvm@11/bin/../include/c++/v1
/usr/local/Cellar/llvm@11/11.1.0_4/lib/clang/11.1.0/include
/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks (framework directory)
End of search list.
^C
上記の#include <...> search starts here:
から下に表示されるパスで必要そうなものをincludePath
に追加する。
(例では(framework directory)は追加していない。)
例:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/opt/llvm@11/bin/../include/c++/v1",
"/usr/local/Cellar/llvm@11/11.1.0_4/lib/clang/11.1.0/include",
"/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include",
],
"defines": [
"__cplusplus"
],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/local/opt/llvm@11/bin/clang",
"cStandard": "c17",
"cppStandard": "c++11",
"intelliSenseMode": "macos-clang-x64",
"compilerArgs": []
}
],
"version": 4
}
参考サイト