Based on this SO post, I created a FindClassDecls.cpp
file and I try to setup a VSCode in macOS to find the required clang headers. So I’ve tried to add the output of these two commands:
-
llvm-config --cflags
and clang -E - -v < /dev/null 2>&1 | grep "^ /" | grep clang
to the “includePath” entry in .vscode/c_cpp_properties.json
. So my .json looks like this:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/opt/homebrew/Cellar/llvm/15.0.7_1/include",
"/opt/homebrew/Cellar/llvm/15.0.7_1/lib/clang/15.0.7/include"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks"
],
"compilerPath": "/opt/homebrew/opt/llvm/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "macos-clang-arm64"
}
],
"version": 4
}
And this is my tasks.json
:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ build active file",
"command": "/opt/homebrew/opt/llvm/bin/clang++",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
However, the required headers are still not found ('clang/AST/ASTConsumer.h' file not found
). These are the first lines of the .cpp file:
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Tooling/Tooling.h"
Any idea what could be missing?
My environment:
> clang --version
Homebrew clang version 15.0.7
Target: arm64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
> llvm-config --version --prefix --includedir --libdir --libs
15.0.7
/opt/homebrew/Cellar/llvm/15.0.7_1
/opt/homebrew/Cellar/llvm/15.0.7_1/include
/opt/homebrew/Cellar/llvm/15.0.7_1/lib
-lLLVM-15