Description
Environment
- OS and Version: Windows 11
- VS Code Version: 1.92.2
- C/C++ Extension Version: v1.21.6
Bug Summary and Steps to Reproduce
Bug summary
The compiler used to provide static analysis is different from the one that provides intellisense for the project. This is probably a wrong configuration on my part, but after navigating through the docs I've been unable to find out how to change that.
My goal is to be able to use gcc (correctly configured following the dedicated guide) in a project that requires it, and while the intellisense is working correctly, the static analysis of underlying libraries shows different errors related to compiler support. I'll provide a minimal example.
Steps to reproduce
- Create a new file
test.cpp
- Provide gcc CompilerPath in
c_cpp_properties.json
- Copy the following code:
#include <iostream>
#include <string>
using namespace std;
int main() {
#if defined(__GNUC__)
cout << "Hello GCC!" << endl;
#else
#error "Unsupported compiler"
#endif
}
As you can see, while the intellisense shows that __GNUC__
is defined, the analysis says it's not. Manually defining it does not solve the problem in my other project because it's actually a different compiler, not a missing definition.
Configuration and Logs
Logs:
-------- Diagnostics - 8/21/2024, 11:08:21 AM
Version: 1.21.6
Current Configuration:
{
"name": "Win32",
"includePath": [
"c:/Users/david/Desktop/test/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.22621.0",
"compilerPath": "Q:/msys2/ucrt64/bin/gcc.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"compilerPathIsExplicit": true,
"cStandardIsExplicit": true,
"cppStandardIsExplicit": true,
"intelliSenseModeIsExplicit": true,
"compilerPathInCppPropertiesJson": "Q:/msys2/ucrt64/bin/gcc.exe",
"mergeConfigurations": false,
"browse": {
"path": [
"c:/Users/david/Desktop/test/**",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
}
}
cpptools version (native): 1.21.6.0
Translation Unit Mappings:
[ C:\Users\david\Desktop\test\test.cpp - source TU]:
Translation Unit Configurations:
[ C:\Users\david\Desktop\test\test.cpp ]:
Process ID: 20388
Memory Usage: 117 MB
Compiler Path: Q:\msys2\ucrt64\bin\gcc.exe
Includes:
System Includes:
Q:\msys2\ucrt64\include\c++\13.2.0
Q:\msys2\ucrt64\include\c++\13.2.0\x86_64-w64-mingw32
Q:\msys2\ucrt64\include\c++\13.2.0\backward
Q:\msys2\ucrt64\lib\gcc\x86_64-w64-mingw32\13.2.0\include
Q:\msys2\ucrt64\include
Q:\msys2\ucrt64\lib\gcc\x86_64-w64-mingw32\13.2.0\include-fixed
Defines:
_DEBUG
UNICODE
_UNICODE
Standard Version: c++17
IntelliSense Mode: windows-gcc-x64
Other Flags:
--g++
--gnu_version=130200
Total Memory Usage: 117 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 3565
Other Extensions
Related installed extensions are:
- Clang-Format
- CMake
Disabling them does not resolve the issue.
Additional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status