microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Unable to resolve configuration with compilerPath "C:\msys64\mingw64\bin\gcc.exe" #8452

Closed 108806 closed 2 years ago

108806 commented 2 years ago

Bug-type: Language Server

Description After installing MSYS2 for windows and trying to use LanguageServer in GCC mode the IntelliSense is being put back in the default win32 mode with the following error being displayed in the extension output window :

Unable to resolve configuration with compilerPath "C:\msys64\mingw64\bin\gcc.exe". Using "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.30.30705\bin\Hostx64\x64\cl.exe" instead.

System info

Steps to reproduce

  1. Have a working and configured msys2 setup with x64 toolchain (https://code.visualstudio.com/docs/languages/cpp ; https://www.msys2.org/).
  2. [CTRL]+[SHIFT]+[P} to launch C/C++ configuration via UI.
  3. Click 'Add Configuration' with a new name ie "g++ MSYS2".
  4. Specify compiler path, usually "C:\msys64\mingw64\bin\g++.exe".
  5. Change IntelliSense mode to windows-gcc-x64 6.Add include dirs recursively to extension include paths, ie "C:\msys64\usr\include**"
  6. Open any c++ and change configuration to the created one, try to use linting

Expected behavior Linting should work in GCC mode, and if a crash occurs then the reason should be specified clearly

Config and logs

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "${vcpkgRoot}/x64-windows-static-md/include",
                "${vcpkgRoot}/x86-windows/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.30.30705/bin/Hostx64/x64/cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64",
            "compilerArgs": [
                "--Wall",
                "--Wextra",
                "-pedantic",
                "-std=c++17"
            ]
        },
        {
            "name": "g++ msys",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\msys64\\usr\\include\\**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "compilerPath": "C:\\msys64\\mingw64\\bin\\g++.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-gcc-x64",
            "compilerArgs": [
                "\"--Wall\"",
                "\"--Wextra\"",
                "\"-pedantic\"",
                "\"-std=c++17\"",
                "\"-g3\""
            ]
        },
        {
            "name": "gcc msys",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\msys64\\usr\\include\\**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "compilerPath": "C:\\msys64\\mingw64\\bin\\gcc.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-gcc-x64",
            "compilerArgs": [
                "\"--Wall\"",
                "\"--Wextra\"",
                "\"-pedantic\"",
                "\"-std=c17\"",
                "\"-g3\""
            ],
            "mergeConfigurations": false,
            "browse": {
                "path": [
                    "${workspaceFolder}/**",
                    "${vcpkgRoot}/x64-windows-static-md/include",
                    "${vcpkgRoot}/x86-windows/include"
                ],
                "limitSymbolsToIncludedHeaders": true
            }
        }
    ],
    "version": 4
}
Colengms commented 2 years ago

Hi @108806 . Could you enable "C_Cpp.loggingLevel": "Debug" and provide the output from the C/C++ output channel leading up to the issue? It should indicate the command line it's using to invoke MinGW that's failing.

I suspect the issue is related to the compilerArgs you specified. When I try to use that configuration, I get the following error:

"C:\\msys64\\mingw64\\bin\\gcc.exe" "--Wall" "--Wextra" "-pedantic" "-g3" -std=gnu++17 -Wp,-v -E -dD -x c++ -m64  nul
gcc.exe: error: unrecognized command-line option '--Wall'; did you mean '-Wall'?
gcc.exe: error: unrecognized command-line option '--Wextra'; did you mean '-Wextra'?
108806 commented 2 years ago

My fault. All good after fixing those args. Closing.