-
-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Recommend the use of compilation database for VS Code #19401
Comments
VS Code C/C++ extension is capable of understanding the standard compile_commands.json. This should be the default recommendation since it provides the most accurate information to the language server. qmk#19401
Is there anything else that can be added to these instructions? I found them while trying to get intellisense working correctly on my M1 macbook to do some work on an RGB matrix animation, but I did not run across an
And I'm getting random and inconsistent
Which isn't particularly clear, and it's not clear what defines I need, since building with the The troubleshooting instructions are also a bit vague. It's not entirely clear what "not matching what you expect" is supposed to mean, and they state "if it's not part of your compilation database, it will tell you so", but I've tried tracking this down, and finding the defines I need is not at all clear. For example, I am starting off by modifying an existing file |
For completness' sake, the output of my C/C++ diagnostics are below. Perhaps something jumps out to you that I missed that we can add to the instructions. I note that
|
Hey @flowchartsman, this is a pull request to improve the documentation RE: the use of compilation database and I think your issue is probably not related. I did look at your issue and I think I kind of know why:
The compilation database (or any C/C++ auto-completes for that matter) work against a compilation unit - which is usually a c/c++ file that is compiled and then results in an object file. The error message is given because
Can you check your compile_commands.json? It's a fairly simple JSON, you should be able to find a list of source code being compiled. Do you see |
Thank you for responding! And yes, I definitely checked it first. I have set the keyboard as default with:
But I have also generated the json file explicitly with
And the result is the same. Include errors all over the place. |
This is why I mention it here. Because I followed the putative new documentation steps, which make sense, and yet VSCode is still behaving unpredictably, so either something is missing from the instructions, or there's an alternate path that I should be taking that is not documented (or it is unclear where to look from the docs) |
Do you mind checking if you specifically see I wouldn't pay attention to the errors that are not in your current open C file. vscode c/cpp tool only operates on individual C files only, and other errors can be inaccurate. RE: the error "expected an identifier" it simply (and vaguely) means it expects an identifier (e.g., a name of a variable) to be followed where it is. For example, given the following file
gcc will complain
Because it expects a function name (an identifier) at line 1, column 6 - but instead there is something else that is not an identifier. The error is necessarily cryptic because the IDE does not have all the right defines, and therefore it's probably parsing a non-syntactical header file to begin with. To rephrase my original points: If you still want it to work, then you have to extract the right defines, include paths from compile_commands.json for one of the source code and configure |
Yes, this is correct. If the file is found in compile_commands.json, vscode seems to ignore the other configs entirely (found out just by trying out things). If the file is NOT found, then vscode uses the defines from that config file. I don't have an M1 mac, but I did check it out under Linux (WSL) using RE: the files you originally reported as not working (e.g., rgb_matrix_effects.inc) I did look at it, the heuristics are correct because rgb_matrix.c does include them. I do see the same errors. There's a lot of macro magic involved though, so my guess is that either the compile_commands.json is not sufficient for vscode to get all the right defines (that's why I included that If you build inside the vscode terminal, you can still jump to problems from the build output - so that's good enough for me. |
I couldn't get If you are using a Mac, replace What did make this work was the following:
CLion worked fine with this, open as a "Compilation database project", not a "Makefile project". VSCode however needed to have the paths added, as it didn't seem to read the I think bear gets stuck when it's wrapped around |
@joshuataylor which paths did you need to update in VSCode? I'm having a challenging time getting all of these errors resolved on an Apple Silicon mac.
Edit:
Edit 2:
|
This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed in the next 30 days unless it is tagged properly or other activity occurs. |
This issue has been automatically closed because it has not had activity in the last 30 days. If this issue is still valid, re-open the issue and let us know. |
Issue Description
The current documentation recommends a VS code setup that's not quite right. VS Code is capable of understanding the standard compile_commands.json database, so we should recommend that as the default setup. I've noticed that #15434 was closed but the documentation for vscode wasn't updated so I am opening this issue to track that.
The text was updated successfully, but these errors were encountered: