Reputation: 309
I have an embedded C project, and want to read it in VSCode with clangd extension. I've built the project and generated compile_commands.json successfully with xmake/cmake. But clangd cannot find (cross compiler's) system headers using the generated compile_commands.json.
According to clangd documentation, I need to pass -isystem
flag to clangd in compile_commands.json. I don't know how. The flags in "arguments" in compile_commands.json are passed to the cross compiler rather than clangd. Run clangd -isystem <path>
results in "Unknown command line argument '-isystem'". Where should I add the -isystem
flag?
Upvotes: 2
Views: 1008
Reputation: 11
Did you tried to pass the -isystem flag to clangd in compile_commands.json by adding the following line to the command field of the relevant JSON object:
css
"-isystem/path/to/system/header/directory"
You can also pass multiple -isystem flags by adding multiple entries to the command field, as shown in the following example:
json
"command": "clang++ -isystem/usr/include -isystem/path/to/other/header/directory file.cpp"
Note that the command field should contain the entire compiler command, including any flags or options you want to pass to clangd.
Upvotes: 1