#VSCode C++ error, getting "cannot open source file "string_view".

70 messages · Page 1 of 1 (latest)

open mural
#

I am getting an intellisense highlight/pop up error
"cannot open source file "string_view". Please run the 'Select IntelliSense Configuration...' command to locate your system headers.C/C++(1696)"
although i did fixed the compiler path, set the language standard to c++17, still getting this error.
Its only happening for MinGW compiler but when i select the Intellisense Configure as cl.exe from MSVC the error isnt highlighted but still the program doesn't run, i am new to vs code environment specifically and i believe the some of the json file settings have been changed, cant figure out what.

heres my
cpp_properties.json file contents

{
    "configurations": [
        {
            "name": "windows-g++-x64",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-gcc-x64",
            "compilerArgs": [
                ""
            ]
        },
        {
            "name": "windows-gcc-x64",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22621.0",
            "compilerPath": "cl.exe",
            "cStandard": "c17",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

Any help would be appreciated

unreal cliff
#

(And the Desktop development workload in Visual Studio)

open mural
#

well i already do coding in visual studio
wanted to try vscode due it being lightweight and for problem solving

open mural
unreal cliff
#

And send the output

open mural
unreal cliff
open mural
#

yes wait

unreal cliff
# open mural yes wait

Then delete your cpp_properties.json. And then press Ctrl+Shift+P and click on Select IntelliSense Configuration. And then select cl.exe

open mural
open mural
#

same error

unreal cliff
#

It sais "Use cl.exe Found at ...". Is the path correct?

open mural
#

well no it doesnt show "Found at"
just cl.exe

unreal cliff
#

Oh, ok

#

Press Ctrl+Shift+P agian and click on C/C++: Edit Configurations (UI)

#

And set the compiler path manually

open mural
#

did that
No change
gives the same error

unreal cliff
#

can you switch your configuration? You are currently working on windows-gcc-x86

open mural
#

yeah changed it to windows-msvc-x64

#

when itry to build with cl
it says
cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt for VS.

unreal cliff
#

and start vscode with code .

#

this will start vscode in your current dir

open mural
#

it works
whenever i type code just code without period it open my recent working directory

unreal cliff
#

👍

open mural
#

by works i didnt mean the code works
the code cmd works🫠

#

should i start from square one?

unreal cliff
open mural
unreal cliff
#

do you have vscode open in your projects dir using the vs cmd promt?

open mural
#

yes

unreal cliff
#

so what error do you get?

open mural
#

i still cant run using cl compiler

open mural
unreal cliff
#

Are you sure that you did run vscode with the Developer Command Prompt for Visual Studio?

#

If so, then try to navigate directly in the prompt to your projects folder and then enter code ., im not sure if that makes any difference

open mural
#

ohh wait i didnt
lol
now i tried

unreal cliff
#

okay, and did it work? 🤨

open mural
#

nah now when i try to run via cl.exe it open launch.json

unreal cliff
open mural
#

yea itellisense is not giving any error

#

its just when i try to run

#

it gives the same error

unreal cliff
#

Choose Àdd Debug Configuration and cl.exe

#

And delete your old launch.json, since this will create a new one

open mural
#

i deleted launch.json
then did add debug config -> cl.exe
it opened launch.json

#

when i run it gives error
i think its using g++ to run the code

#

instead of clang

unreal cliff
#

Share the json

open mural
#

does it have anything to do with settings.json??

#

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C/C++ Runner: Debug Session",
            "type": "cppdbg",
            "request": "launch",
            "args": [],
            "stopAtEntry": false,
            "externalConsole": true,
            "cwd": "d:/WorkSpace/VisualStudioCode/Practice/learncpp",
            "program": "d:/WorkSpace/VisualStudioCode/Practice/learncpp/build/Debug/outDebug",
            "MIMode": "gdb",
            "miDebuggerPath": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        },
        {
            "name": "C/C++: cl.exe build and debug active file",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "console": "integratedTerminal",
            "preLaunchTask": "C/C++: cl.exe build active file"
        }
    ]
}
unreal cliff
#

hmm, weird

#

and what exact error do you get again when executing this?

unreal cliff
open mural
#

cpp_properties.json file contents

{
  "configurations": [
    {
      "name": "windows-gcc-x86",
      "includePath": [
        "${workspaceFolder}/**"
      ],
      "compilerPath": "C:/MinGW/bin/gcc.exe",
      "cStandard": "c17",
      "cppStandard": "c++17",
      "intelliSenseMode": "windows-gcc-x86",
      "compilerArgs": [
        ""
      ],
      "mergeConfigurations": false,
      "browse": {
        "path": [
          "d:/WorkSpace/VisualStudioCode/Practice/learncpp/**",
          "d:/WorkSpace/VisualStudioCode/Practice/learncpp"
        ],
        "limitSymbolsToIncludedHeaders": true
      },
      "compilerPathInCppPropertiesJson": "gcc.exe"
    },
    {
      "name": "windows-msvc-x64",
      "includePath": [
        "${workspaceFolder}/**"
      ],
      "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
      ],
      "windowsSdkVersion": "10.0.22621.0",
      "cStandard": "c17",
      "cppStandard": "c++17",
      "intelliSenseMode": "windows-msvc-x64",
      "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe"
    }
  ],
  "version": 4
}
unreal cliff
#

compilerPath correct?

open mural
#

yes

unreal cliff
#

im not pretty sure, but can you try to remove this part just to test:

    {
      "name": "windows-gcc-x86",
      "includePath": [
        "${workspaceFolder}/**"
      ],
      "compilerPath": "C:/MinGW/bin/gcc.exe",
      "cStandard": "c17",
      "cppStandard": "c++17",
      "intelliSenseMode": "windows-gcc-x86",
      "compilerArgs": [
        ""
      ],
      "mergeConfigurations": false,
      "browse": {
        "path": [
          "d:/WorkSpace/VisualStudioCode/Practice/learncpp/**",
          "d:/WorkSpace/VisualStudioCode/Practice/learncpp"
        ],
        "limitSymbolsToIncludedHeaders": true
      },
      "compilerPathInCppPropertiesJson": "gcc.exe"
    },
open mural
#

ok i did

#

no change

#

now intellisense is back to giving error

unreal cliff
#

interesting

open mural
#

😭

unreal cliff
#

wasn't intellisenes configured to windows-msvc-x64?

open mural
#

yes