KLJ
KLJ

Reputation: 151

VS Code - How to setup the c_cpp_properties.json file for multiple Win32

I am looking for the correct way of setting up the paths in the mentioned .json file. I am working with different PCs, using Git to merge both and "sadly" the paths to the MinGW libs are different.

{
"configurations": [
    {
        "name": "Win32",
        "includePath": [
            "${workspaceFolder}/**"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE",
            "_UNICODE"
        ],
        "browse": {
            "path": [
                "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0",
                "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"
            ]
        },
        "intelliSenseMode": "msvc-x64"
    }
],
"version": 4}

Is it now correct to add just the paths of both PCs so that one PC each is looking to the wrong path?

Upvotes: 1

Views: 5051

Answers (1)

Andrew
Andrew

Reputation: 26

I used the approach of setting an environment variable i.e. MINGW_GCC_PATH on each PC which can then be used via ${env:MINGW_GCC_PATH} in your case:

    "browse": {
        "path": [
            "${env:MINGW_GCC_PATH}"
        ]
    },

In my case instead of setting "browse" {...}, I used:

    "compilerPath": "${env:MINGW_GCC_PATH}/bin/gcc.exe",

NOTE: As you are using gcc I would also recommend changing "intelliSenseMode": "msvc-x64" to "intelliSenseMode": "gcc-x64"

Upvotes: 1

Related Questions