Vscode-cpptools: Setting C++ standard

Created on 18 Jan 2018  路  6Comments  路  Source: microsoft/vscode-cpptools

I've recently started using VSCode (and the cpp tools extension alotng with it).
I've looked through the documentation multiple times but for the life of me I cannot figure out how/where to set the C++ standard.

I apologise if this has been asked (and answered) before, but no Google search came up with something relevant.

Any help would be greatly appreciated.

==EDIT==
Actually I did some re-configuration to both my system and visual studio code and now it's working perfectly, thus I'm closing this question
Thank you very much for your help

Language Service question

Most helpful comment

Still have the same problem. My configuration file is as follows


{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1",
                "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/x86_64-pc-linux-gnu",
                "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/backward",
                "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/include",
                "/usr/local/include",
                "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/include-fixed",
                "/usr/include",
                "${workspaceRoot}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1",
                    "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/x86_64-pc-linux-gnu",
                    "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/backward",
                    "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/include",
                    "/usr/local/include",
                    "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/include-fixed",
                    "/usr/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }],
    "version": 3
}

Here's a screenshot of a sample error
image

And another
image

All 6 comments

The setting is not exposed yet. We default to c11 and c++17, but our compiler doesn't support all the c++17 features yet. You could try changing the version used by modifying the ~/vscode/extensions/ms-vscode.cpptools-0.14.6/bin/msvc.json file which has a reference to the version to use (e.g. c++03, c++11, c++14, c++17).

The problem I had was that c++11 specific functions (i.e. std::stoi) where not recognised. Could this have been a fault in my setup?

Yeah, sounds like your includePath/defines aren't correct (see https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/FAQ.md#why-do-i-see-red-squiggles-under-standard-library-types ). We should work with c++11 without any changes. What OS/compiler are you using?

I'm on Linux. I switched to clang in the settings but did not change anything else. I'll try with gcc and let you know. Thank you very much.

If you continue to have issues, please share the contents of your c_cpp_properties.json file so we can verify your configuration.

Still have the same problem. My configuration file is as follows


{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1",
                "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/x86_64-pc-linux-gnu",
                "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/backward",
                "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/include",
                "/usr/local/include",
                "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/include-fixed",
                "/usr/include",
                "${workspaceRoot}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1",
                    "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/x86_64-pc-linux-gnu",
                    "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/backward",
                    "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/include",
                    "/usr/local/include",
                    "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/include-fixed",
                    "/usr/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }],
    "version": 3
}

Here's a screenshot of a sample error
image

And another
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wdc596933938 picture wdc596933938  路  3Comments

jrieken picture jrieken  路  3Comments

montery8 picture montery8  路  3Comments

thndrwrks picture thndrwrks  路  3Comments

arl picture arl  路  3Comments