Visual studio code C++ on Linux Manjaro: IncludePath issue

狂风中的少年 提交于 2019-12-06 10:34:43

问题


I am trying to configure my Visual Studio Code to developing C++ code on Linux Manjaro (last release), but I have a little bit of a problem.

Under the green line I had this description:

#include errors detected. Please update your includePath. IntelliSense features for this translation unit (/home/waski/myTest/myTest.cpp) will be provided by the Tag Parser. cannot open source file "stddef.h" (dependency of "iostream")

In c_cpp_properties.json file, section Linux, I have this config:

{
        "name": "Linux",
        "includePath": [
            "/usr/include/c++/7.1.1",
            "/usr/include/c++/7.1.1/x86_64-pc-linux-gnu",
            "/usr/local/include",
            "/usr/include",
            "${workspaceRoot}"
        ],
        "defines": [],
        "intelliSenseMode": "clang-x64",
        "browse": {
            "path": [
                "/usr/include/c++/7.1.1",
                "/usr/include/c++/7.1.1/x86_64-pc-linux-gnu",
                "/usr/local/include",
                "/usr/include",
                "${workspaceRoot}"
            ],
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": ""
        }
    },

I also installed the c/c++ extension. In my opinion, includePath is fully complex, I have no idea, which patch is required also.


回答1:


I had exactly same problem today. Here's how I fixed it:

Find where on your system do you have stddef.h for example by running sudo find / -name stddef.h

Mine for example returns:

/usr/include/linux/stddef.h
/usr/lib/clang/4.0.1/include/stddef.h
/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/include/stddef.h

Pick any of these paths and add it to c_cpp_properties.json file, into includePath. You should be good to go then.




回答2:


Your c_cpp_properties.json is missing the compilerPath attribute, so VSCode might be using the wrong compiler. To check, in the Command Palette (Ctrl+Shift+P), run "C/C++: Log Diagnostics". That will show the compiler path.

Also compare the output you see there to the output of:

  $ touch empty.c
  $ gcc -v -E -dD empty.c

At a minimum, you want the #include search paths to agree.

In this answer I have written up generic instructions on how to troubleshoot C++ compiler configuration in VSCode.



来源:https://stackoverflow.com/questions/45855519/visual-studio-code-c-on-linux-manjaro-includepath-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!