Closed codimoc closed 1 year ago
Can you run the C/C++: Log Diagnostics command before and after the IntelliSense mode seems to change and see if the Standard Version changes from c++20 to c++17 in the logging? Also, in that logging do you see c++17 in the "Custom configurations:" sections, such as in compilerFragments? Checking if the issue repros when "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
is removed could also help.
Thanks Sean. Today it seems that the error squiggles stay there also after a "Reload windows". They are not displayed only when the folder is loaded on start-up. However, apart from date, time and process id, the C++ log diagnostic is basically the same. Here is a copy: Thx
`-------- Diagnostics - 15/05/2023, 19:36:17 Version: 1.15.4 Current Configuration: { "name": "Linux", "includePath": [ "/home/gualtiero/proj/Cpp/cpp_features/" ], "defines": [], "compilerPath": "/usr/bin/clang", "cStandard": "c17", "compilerPathInCppPropertiesJson": "/usr/bin/clang", "cppStandard": "c++20", "intelliSenseMode": "linux-gcc-x64", "intelliSenseModeIsExplicit": true, "cStandardIsExplicit": false, "cppStandardIsExplicit": true, "mergeConfigurations": false, "compilerPathIsExplicit": false, "configurationProvider": "ms-vscode.cmake-tools", "browse": { "path": [ "${workspaceFolder}/" ], "limitSymbolsToIncludedHeaders": true } } Custom browse configuration: { "browsePath": [ "/home/gualtiero/proj/Cpp/cpp_features/build/CMakeFiles", "/home/gualtiero/proj/Cpp/cpp_features/src" ], "compilerPath": "/usr/bin/g++", "compilerArgs": [], "compilerFragments": [ "-g", "-std=gnu++2a" ] } Custom configurations: [ /home/gualtiero/proj/Cpp/cpp_features/src/concepts.cpp ] { "includePath": [], "defines": [], "compilerPath": "/usr/bin/g++", "compilerArgs": [], "compilerFragments": [ "-g", "-std=gnu++2a" ] } Translation Unit Mappings: [ /home/gualtiero/proj/Cpp/cpp_features/src/concepts.cpp ]: /home/gualtiero/proj/Cpp/cpp_features/src/concepts.cpp Translation Unit Configurations: [ /home/gualtiero/proj/Cpp/cpp_features/src/concepts.cpp ]: Process ID: 4164 Memory Usage: 95 MB Compiler Path: /usr/bin/g++ Includes: /usr/include/c++/10 /usr/include/x86_64-linux-gnu/c++/10 /usr/include/c++/10/backward /usr/lib/gcc/x86_64-linux-gnu/10/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include Standard Version: c++20 IntelliSense Mode: linux-gcc-x64 Other Flags: --g++ --gnu_version=100201 Total Memory Usage: 95 MB
------- Workspace parsing diagnostics ------- Number of files discovered (not excluded): 20836
`
Hmm...I'm not reproducing the issue and your logging looks okay. One potential thing to try is setting C_Cpp.intelliSenseCacheSize to 0. Otherwise, I'll see if anyone else on my team can repro this.
Thanks Sean. C_Cpp.intelliSenseCacheSize=0 does not solve. To be more precise, as soon as the settings file is changed, the squiggles disappear as if it is working. For any editing of the active cpp file, the squiggles come back. I wonder: do you have any configuration where you declare a concept in VS C++ and it does not show any error?
Basically, is it possible to have the following without Intellisense squiggles:
template\<typename T> concept Numeric = std::integral\<T> || std::floating_point\<T>;
Thanks
Yes, that normally works (it works for us). We're not sure yet why you're seeing an error.
hmm, that is strange. Have you tried to write a test file test.cpp, with the two lines above. Now, assuming no squiggles, adding an empty line at the end. That, or any other edit, generate the errors. Notice that it only happens with this feature, C++17 features behave well. Basically I am migrating out of Eclipse CDT and so far VS Code is the best, apart from this. You guys are doing a great work!
It works for me with a nearly identical setup -- the only difference I see is I'm using gcc 10.4 instead of 10.2 -- can you upgrade your gcc to 10.4? It's possible there could be a bug with our handling of 10.2.
ok, I will see if I can install on Debian 11. Thx
Hmm, built gcc 10.4 from source, gcc -v shows 10.4 now and in config: --gnu_version=100400
However the problems remains :(
...And again "Reload Window" or re-saving settings solves the problem until the next edit...
And this is also interesting. When I play with the settings:
So this suggest that c++20 works at the begging but then is dropped for any edit action. Really weird
Do you still have the configurationProvider set? It sounds like you do not.
Are you editing a .cpp or .h file?
Tried both h and cpp, same problem I have re-added configurationProvider in local settings: { "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools" } same problem
Could you please send me a copy of all the settings files you are using: main config setting, local settings and, if present, c_cpp_properties.json? Also, shall I use this file (c_cpp_properties.json) or just the local settings and config settings? Not clear to me
@codimoc Unfortunately, our team is still unable to repro this. We're using "C_Cpp.default.cppStandard": "c++20"
.
The fact that it shows c++20 in the Log Diagnostics logging but the errors are still occurring seems to imply there is some unexpected parsing error.
Can you run /usr/bin/g++ -std=gnu++2a -E ./test.cpp > ./test.out.cpp
to generate a preprocessed file and then open the file and see if there are any IntelliSense errors in that file and if the bug repros with that file still? That will rule out any issue related to the headers or our processing of the header.
No squiggles/ errors in test.out.cpp, even after editing. The file has many lines at the top (I guess from #include concepts) and ends with:
# 2 "./test.cpp" 2
# 2 "./test.cpp"
template
So it looks like as if Intellisense gets confused in parsing my \<concepts> while gcc does a good job when it spits it out at the top. Could it be the depth of the cache when parsing many nested #includes?
Maybe this could be a clue. When I check the output for "JSON Language Server" in the bottom output tab, it shows only one line: cancelled. Is this normal?
Wow! I have finally resolved the problem. It was very insidious, and this is the story on how I got it solved:
I have another Linux box with OpenSuse 15.4. Opensuse tends to have old versions, so my gcc was still v7, but I upgraded from source to v10.4, in line with my Debian laptop. The C++ extension was the same version on the two machines, while VS on OpenSuse was a few main versions behind (but this was not the problem). Now, I wrote my test.cpp with the "concept" declaration and c++20 standard for Intellisense: on this machine it all worked fine. Then, by comparing the configuration logs, and trying to make them match with each other, I removed a few setting and realized that my Debian defaults to a clang compiler (not gcc which is the default for the other machine) and that I had a clang installation on Debian. I uninstalled clang and now all my problems on Debian are solved. Hurrah!!
Thanks a lot for the support and the many suggestion given. You helped a lot understanding how it all hang toghether. This case can now be closed. :)
Environment
Bug Summary and Steps to Reproduce
Bug Summary: When setting Intellisense to use C++ 20 standard and displaying a file containing keywords like "concept" or "requires" (which are features in C++20) it works. As soon as the file is edited again, it seems that it is losing the standard and it shows errors on "concept" as missing symbol. Basically it shows errors as if the standard is back to C++ 17. Any action to reload the workspace or to re-save the file .vscode/settings resolves the errors. However they come back as soon as the file is re-edited.
Steps to reproduce:
template concept Numeric = std::integral|| std::floating_point;
Other Extensions
No response
Additional context
No response