Vscode-cpptools: #include errors despite correct include/browse path

Created on 12 Sep 2017  路  3Comments  路  Source: microsoft/vscode-cpptools

I use Visual Studio Code (version 1.15.1) with the _ms-vs-code.cpptools_ extension (version 0.12.3) on Windows 10. I have created a simple C++ project with a singe cpp file and some configuration files in the .vscode subfolder. I also added cpp_properties.json (which is listed below) to get intellisense support. Unfortunately, VS code does not honor the include path defined herein. I always get green swiggles under #include directives saying #include errors detected. Please update your includePath. ....

In the local settings.json file I have set C_Cpp.intelliSenseEngine to "Default".

When I select a line with an #include directive and navigate to the definition (F12) the header file is opened as expected. So the include paths seems to be correct.

What's also strange is, that the before mentioned warning disappears when I select the correct configuration using the command C/Cpp: Select a configuration .... I have to repeat this command everytime I switch back to the corresponding cpp file.

Is this an error in the plug-in or a configuration error?

c_cpp_properties.json:

{
        "configurations": [{
                "name": "MinGW on Windows",
                "intelliSenseMode": "clang-x64",
                "includePath": [
                        "${workspaceRoot}",
                        "D:\\bin\\swo3\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\7.2.0\\include",
                        "D:\\bin\\swo3\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\7.2.0\\..\\..\\..\\..\\include",
                        "D:\\bin\\swo3\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\7.2.0\\include-fixed",
                        "D:\\bin\\swo3\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\7.2.0\\..\\..\\..\\..\\x86_64-w64-mingw32\\include"
                ],
                "browse": {
                        "path": [
                                "${workspaceRoot}",
                                "D:\\bin\\swo3\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\7.2.0\\include",
                                "D:\\bin\\swo3\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\7.2.0\\..\\..\\..\\..\\include",
                                "D:\\bin\\swo3\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\7.2.0\\include-fixed",
                                "D:\\bin\\swo3\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\7.2.0\\..\\..\\..\\..\\x86_64-w64-mingw32\\include"
                        ],
                        "limitSymbolsToIncludedHeaders": true,
                        "databaseFilename": ""
                }
        }],
        "version": 2
}

Most helpful comment

what a nightmare for 2018

All 3 comments

We have a MinGW FAQ at https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/MinGW.md -- you may also need to add __stdcall=__attribute__((__stdcall__)) .

We have a bug in which we don't update the squiggle errors after switching a configuration. You may just want to keep your configuration named "Windows" so you don't have to switch.

Let us know if you're still having problems.

Thank you for your hint concerning the configuration name. Btw., the correct name is "Win32", not "Windows".

The actual reason for my problem was that I used the include paths for C, but not for C++.

For anyone who is interested: These paths can be generated with echo | gcc -Wp,-v -x c++ - -fsyntax-only. But never omit the option -x c++ (as I did) if you need the paths for C++.

what a nightmare for 2018

Was this page helpful?
0 / 5 - 0 ratings

Related issues

montery8 picture montery8  路  3Comments

ecbrodie picture ecbrodie  路  3Comments

jyavenard picture jyavenard  路  3Comments

jrieken picture jrieken  路  3Comments

chrisckc picture chrisckc  路  3Comments