Open harnyang opened 1 week ago
Hi @harnyang . I'm not able to reproduce an issue with your example, when using a default installation of MSYS2 (Using g++.exe
from either mingw32, mingw64 or ucrt64 packages).
Could you try setting "C_Cpp.loggingLevel": "Debug"
and providing the log output from the C/C++ output channel, from startup until the repro?
The C/C++ extension will 'query' a compiler (if clang or gcc) to solicit its system include paths. It sounds like something may be going wrong with that process. The log of those attempts to query the compiler may provide some clues.
Also, once the issue repro's, could you run the C/C++: Log Diagnostics
command, and provide the results? That should indicate exactly what configuration was used for the open file.
"D:/software/courseware/minGW/mingw64/lib/**",
"D:/software/courseware/minGW/mingw64/lib/gcc/x86_64-w64-mingw32/14.2.0/include/C++/**",
"D:\\software\\courseware\\minGW\\mingw64\\x86_64-w64-mingw32\\include\\**"
Since the C/C++ Extension will query system include paths from the configured compiler, you'll want to omit any system include paths from your user includes, as this can result in issues due to include path order.
@harnyang In addition, you could be hitting https://github.com/microsoft/vscode-cpptools/issues/12842, i.e. it could be fixed if you try 1.23.0 (pre-release).
Environment
1.95.1 (user setup) 65edc4939843c90c34d61f4ce11704f09d3e5cb6 2024-10-31T05:14:54.222Z Electron: 32.2.1 ElectronBuildId: 10427718 Chromium: 128.0.6613.186 Node.js: 20.18.0 V8: 12.8.374.38-electron.0 OS: Windows_NT x64 10.0.22631
I’m using the latest version of the C/C++ extension in Visual Studio Code on Windows 11 with the MINGW64 compiler. Here is my compiler information:
My
settings.json
in the workspace is configured as follows:Additionally, my
c_cpp_properties.json
file is set up like this:With this setup, my code compiles and runs correctly. However, I’m getting an error indicating that
<iostream>
cannot be found and thatstdlib.h
(a dependency of<iostream>
) is missing. The error message suggests running "Select IntelliSense Configuration..." to locate system headers. When I trace the error by following the<iostream>
include chain, I end up instd_abs.h
, where the error is flagged with messages like "expected identifier" and "expected ';'". This issue does not occur with older versions of the C/C++ extension (from two months ago) or when using theclangd
extension as the language server. This behavior suggests that there might be a bug in the recent C/C++ extension versions.Here’s my simple test program, which compiles and runs without issues, despite the header file errors:
Could this be a bug in the latest updates to the C/C++ extension?
Bug Summary and Steps to Reproduce
Bug Summary:
Steps to reproduce:
Expected behavior:
Configuration and Logs
//c_cpp_properties.json { "configurations": [ { "name": "Win32", "includePath": [ "${default}", "${workspaceFolder}/", "D:/software/courseware/minGW/mingw64/lib/", "D:/software/courseware/minGW/mingw64/lib/gcc/x86_64-w64-mingw32/14.2.0/include/C++/", "D:\software\courseware\minGW\mingw64\x86_64-w64-mingw32\include\" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "intelliSenseMode": "windows-gcc-x64", "compilerPath": "D:\software\courseware\minGW\mingw64\bin\g++.exe", "cppStandard": "c++11", "cStandard": "c99" } ], "version": 4 }
Other Extensions
No response
Additional context
No response