Skip to content

Update installation.md #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update installation.md #128

wants to merge 1 commit into from

Conversation

shiinakaze
Copy link

Added the case of not using compile_commands.json.

Copy link
Contributor

@HighCommander4 HighCommander4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. compile_commands.json
  2. Compiler key 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.)

@shiinakaze
Copy link
Author

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:

  1. compile_commands.json
  2. Compiler key 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants