Conversation
HighCommander4
left a comment
There was a problem hiding this comment.
There are two things that we shouldn't confuse here.
1. Telling clangd about the project's compile flags, e.g. -I paths and -D flags.
This is needed for any non-trivial project. It can be done either through compile_commands.json, or compile_flags.txt.
This is what this "Project setup" section is talking about.
2. Getting clangd to find the correct system headers.
This works "out of the box" in most cases, no extra configuration needed.
In some cases (cross-compilation, MinGW), clangd can't figure out the system headers on its own and needs to query them from the compiler driver, so this needs to be enabled using --query-driver.
In such cases, clangd also needs to know what compiler to query, this info can come from two places:
compile_commands.jsonCompilerkey in config file
So, it would not be accurate to say that the Compiler key is an alternative to compile_commands.json in general -- it does not provide any way for clangd to learn the project's compile flags.
I do think it would be good to make it easier to find information about getting clangd to find system headers. (We have this guide but it's hard to find and it goes into more detail than the average user needs.) I will look into writing something like that. (There are also improvements we can make in the program itself, like clangd/clangd#1896.)
Thank you for your explanation. Since I couldn't find detailed information in the documentation, such as (Compiler and --query-driver), I came to supplement it. Could you please include these in the documentation? |
Added the case of not using compile_commands.json.