-
Notifications
You must be signed in to change notification settings - Fork 1.5k
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Problem with .C files being associated with C instead of C++ with 0.26.1 #4632
Comments
VS Code itself isn't able to differentiate between the ".c" and ".C" so we have code that should add the sourceFile.C to your files.associations setting in your workspace. Do you see that setting added? If not, what happens when you add it manually for that file? |
Also, unrelated to the c11 issue, but you should remove the system includes from your includePath (it could cause incorrect include path ordering with the other system includes obtained from the compilerPath). |
@sean-mcmanus Thanks for responding. The problem does appear to be related to the The file association for that particular translation unit was missing on extension version 0.26.1. When I reverted back to version 0.24.1, the extension automatically added the file association for that specific translation unit in my workspace settings.json. Upgrading to 0.26.1 with the file association still present fixed the issues I was seeing. I also tried reverting back to 0.24.1 and removing the file association manually before upgrading. After the upgrade to 0.26.1, the file association was not automatically added, and I saw the same issues. Adding the file association manually after upgrading to 0.26.1 resolved the problems. The reason I had the system includes manually defined in my includePath was that C++ standard library headers were not being detected. I was seeing errors like this:
I think these two problems are related. If the file association is not updated properly for a translation unit, and the C++ extension uses the c11 standard instead of C++11 standard, then the compiler does not report the C++ standard library include paths. Here's the Log Diagnostics output after removing the manually-defined entries from
Note that the
So I guess the remaining question is why the file associations are not being updated properly in 0.26.1? Please let me know if you need any additional information |
I should also mention that I already have wildcard file associations in my workspace settings that should apply to all files with .C and .H extensions.
|
Yeah, the |
Well, I used to have an association that looked like this: I thought this was valid syntax, but it seems like on version 0.24.1, the extension was adding specific file associations for each one of my .C files. After moving to 0.26.1, those filename-specific associations were not being added by the extension anymore, and that was causing the problems. I just recently (within the past hour, as I was trying to reproduce) changed that association to look like this:
I was still seeing some issues immediately after the change, but this time I fully closed and restarted VS code after making the change, and I haven't been able to reproduce any problems in 0.26.1 since then. |
Oh, that sounds good. Let us know if you still encounter a problem. |
@sean-mcmanus After making the changes I mentioned above to the files.associations setting, I've still been periodically encountering issues where C++ standard library includes are not being recognized. I was able to reproduce include errors 100% of the time with some specific files in my project directory. I've since narrowed it down to a very small workspace configuration which still reproduces the error every time on my system. I've attached a .tar.gz containing the files for this minimal workspace. I'm running VSCode on Windows 10, but I'm using the Steps I take to recreate:
Repeating steps 2-4 yields the same results.
Results of running
The C++ extension is still using the c11 standard version for this file instead of C++11, even though the Interestingly enough, the C++ extension works perfectly fine if I follow the following steps:
This project (although contrived) does build and run successfully by running |
Hi @bwarrum-ibm . It looks like we are not handing ".H" files as C++. File associations are based on the name of the file that was opened, not the file selected to use for the translation unit, unfortunately. This should be fixed by: #4639 |
I'm still seeing some issues with this on 0.26.2-insiders2. (I think the fix for this went into the 0.26.2-insiders2 release, apologies if I'm mistaken). Seeing the same sort of issue as before, where the incorrect standard version is being applied for C++ source files, and the C++ standard library header files are not added to the include path. Here are the Log Diagnostics (I've edited some directory and source file names due to confidentiality, but all the file extensions in the output are the same)
And
|
Yeah, sorry about the confusion -- I still repro the bug. |
Hi @bwarrum-ibm . It looks like there were multiple issues here. We have a fix ready to go out in the next release, and have confirmed it against your repro. :) |
Hi @bwarrum-ibm . Your repro should be addressed by 0.26.2-insiders3. |
I seem to be having a similar issue on my system. I am working on a C++ project and the extension does not seem to be handling C++ syntax properly, as people have mentioned above in this issue. I have been manually reverting the C++ extension back to version 0.24.1, as that seems to be the most recent extension version where the problem does not occur.
I ran the
C/C++: Log Diagnostics
command on both versions of the extension, and I've noticed that theStandard Version
is different for the same translation unit. I have redacted some project-specific information (includes, source file names) from the output, as it may be confidential and I don't feel comfortable sharing it.The output for version 0.24.1 is almost identical, but the
Standard Version
is c++11 instead of c11. Is it possible that the 0.26.1 version of the extension is treating the C++ source files as C source files instead? I thought that might explain why it seems C++ specific syntax is not being handled properly. Our naming conventions for our C++ source and header files are somewhat abnormal (.C/.H), but it doesn't seem like this was a problem in earlier versions of the extension. I have the language mode set to C++ for these filename extensions, and I've verified that the language mode setting for this specific translation unit is C++ (not sure if that makes a difference)Originally posted by @bwarrum-ibm in #4614 (comment)
The text was updated successfully, but these errors were encountered: