问题
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