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
.h files interpretted as C #12
Comments
Hey, @HaberR! Thanks for giving the tool a try. Sorry things aren't working as expected.
We also have files like this internally. That behavior is super annoying, so we spent time trying to make this case work for everyone. Sorry that isn't working for you; there must be a subcase we hadn't considered. Let's figure out where things are going wrong!
It's be great to figure out where in the process things are going wrong. Could I ask for your help? (I'm assuming there isn't public code I can play around with?) For a given .h file that's giving us trouble:
Anyway, lmk! I'll also run some tests over here shortly. |
Thanks for getting back to me, I've confirmed that:
Here's the clangd output when I open the file: Not sure if it's any help, but the specific errors VSCode references are: I can get the -fno-canonical-system-headers error to go away by deleting that from compile_commands, but deleting --std=c++17 seems to just push the issue further along (I get cstddef not found elsewhere). |
clangd 13 otherwise wrongly assumes them all them are C, regardless of the source file being compiled in the command. #12
Yeah, of course. Thanks for digging in. That that really narrowed down the problem. I can reproduce the issue! Or at least the Further, I can solve it by manually specifying the language, inferring it from the extension from the source file that included it! I've just pushed up a commit that does just that. (In the background: Clangd 13 seems to detect the language from the file name, assume all .h files are C, and then ignore any evidence in the command to the contrary.) Woo. Okay! So could you let me know if that fixes things for you? |
[I don't anticipate that commit fixing the |
Amazing, it works!!! This is awesome, nobody should have to develop without autocomplete. I do still see the squiggle for |
Huzza! Delighted to hear it, @HaberR. Good autocomplete makes me smile, too :) Thank you for bringing this up and for working with me to narrow it down and fix it. It'll help out a lot of others, too. Please let me know if there are other rough edges you see--or if you have ideas on how to make things even better. -Chris |
Hey so one other update: The (awesome) clangd folks are going to fix this case, after some discussion. See https://reviews.llvm.org/D116167 for more. When it's released, I'll test and then revert my workaround to keep things clean and simple. |
@HaberR, could I ask for your help? In a sec, I'm going to revert the workaround, since clangd 14 was just released, which should contain their fix for the underlying problem. Could I ask you to quickly update (both this tool and clangd) and make sure that the issue doesn't come back? I've tested quickly myself, but I'd love it if you'd double check. Plus, there are a lot of good fixes in the latest :) -Chris |
Hi, sorry for the delay, just seeing this, thanks for checking in! I am actually bumping into this issue again.. I'm wondering if maybe it's because I didn't execute:
I'm running my code server on a remote machine and only connecting to it locally--I don't think those instructions would work for my case? At the top of my
Running clangd v0.1.17, and compile-commands-extractor |
Hey, @HaberR! Thanks for reaching back out. Trying to scope: Sounds like the error is back for you now that I reverted the workaround--clangd having released a fix to the underlying issue. I'm assuming that this reemerged when you updated this tool to include the commit that undid the workaround. Is that right? Could I first ask you to confirm that you're using the latest clangd (>=14)? (That is, at least version 14 of clangd the binary--not just the latest vscode extension.) You can double check this by looking at the top of clangd's output in VSCode (View>Output, then select clangd from the dropdown). And if clangd is too old, you can update by opening the command palette and typing "clangd check for update". Sorry for the hassle; just want to make sure that the solution isn't as simple as upgrading clangd. [I'm afraid I haven't used all this with a remote dev environment, so I'm not sure how clangd works with all that. But if it worked before, then it seems more likely that the problem is the above.] |
gah, yup wrong clangd binary, upgrading that fixed it. Thank you, and sorry for the trouble! |
Woo! Great. Good you wrote in--and glad it's working. While we're chatting, anything special users should know if they're trying to set things up for remote dev? Or does it just work out of the box? I'm also curious how you're approaching updating this tool in your WORKSPACE--just so I can keep tabs on what folks are doing. [And if there's anything else feedback wise that I should know, really, please say! I'd love to hear it.] |
Don't remember needing to do anything special--I think it just worked right out of the box! Re our usage: In order to make the setup a little easier for the rest of my team, I've added the clangd config to our
and that doesn't happen from within the container. Unfortunately that single issue can throw a good chunk of the type-checking off (also unfortunate is the fact that we include that library in lots of places). I appreciated some of the new features (automatic symlinks, more readable compile_commands.json, automatic .gitignore update). My only complaint is that it can be a touch slow for the intellisense to kick in when I open a new cc file (3 seconds?) but that's a small price to pay! I know the recommendation is to use Renovate for the purpose of updating our dependencies, but I don't think we have any such tool in place... At the moment I think our upgrade strategy is to do it when someone notices a new feature that they want (or when they're forced to) 😬 |
Sweet. Thank you so much @HaberR for your unfiltered feedback there. It really helps improve my mental model of how you (and others!) use this. Sounds like with the attach you manage to get around that issue? (Please lmk if wrong--not sure I'm totally sure what's going on, but I'm guessing it has to do with referencing STL headers at locations only found inside the container.) On the speed: Pretty sure that's clangd's indexing speed, sadly. (We're just generating the compile_commands.json, which I'd like to make faster, too!) CCLS is a bit faster, apparently, but I think clangd is probably the right call long term. And I appreciate your honestly about Renovate! While I'd recommend it, I really appreciate your telling me that you don't use it. No need to feel bad. In fact, incredibly valuable to help me get a sense of how people are actually approaching updates. Thanks again! |
Hi! So I recently demoed this tool to some of my teammates and I've gotten a lot of love for it, and wanted to forward that your way! Daniel wrote me A few follow ups
|
Hey, I'm so glad. Puts a big smile on my face that this is helping you guys. Thanks for forwarding :) I'm curious what you all are building together with it! |
I work for Third Wave Automation, we're building autonomous forklifts! |
I'm working on a project in which we use .h files for cpp headers. For some reason, clangd treats these like C files after I've run the hedron commands extractor, and then VSCode complains a lot because we're including C++ libraries in what it perceives to be C code. Is there some extra piece of config I can provide to either this tool, or to clangd directly that will instruct it to treat these files like cpp?
The text was updated successfully, but these errors were encountered: