ska*_*arl 5 c++ linux visual-studio-code
我刚刚为 linux ubuntu 14.04 下载了 Visual Studio 代码。我创建了一个简单的 test.cpp 并在 vscode 中编写它并且智能感知不起作用。
这是 test.cpp 中的代码:
struct test{
int a = 5;
}
int main(){
test t;
t.
}
Run Code Online (Sandbox Code Playgroud)
当我写“t”时,没有智能感知告诉我 t 的成员。应该有。
我在 linux 终端中使用命令“touch test.cpp”创建了 test.cpp 文件,然后我用 Visual Studio 代码打开了 test.cpp 并编写了代码。截图可以在这里看到:http : //i.stack.imgur.com/fLhSA.png
任何人都知道如何让智能感知在 linux 中为 vscode 工作?
正如其他人建议的那样,您现在可以添加C/C++ 扩展。
您可能会遇到以下两个扩展问题:
该扩展程序不检测自定义库:
您必须添加自定义库的包含路径。请执行下列操作:
Ctrl + Shift + P
C/C++ 扩展:配置
包含路径(每行添加一个路径,例如)
${workspaceFolder}/**
/home/me/Documents/my_custom_lib/
Run Code Online (Sandbox Code Playgroud)
扩展突然停止,不再给你任何建议:
如果您不打开项目根目录,而是打开它的子项,则可能会发生这种情况。打开项目根文件夹并重新加载窗口。
以下主要适用于使用 ROS1,使用 vscode 的C/C++ 扩展:
在文件中.vscode/c_cpp_properties.json(由VSCode ROS 扩展生成),尝试"cppStandard": "gnu++14"将"cppStandard": "c++14".
该文件看起来像这样:
{
"configurations": [
{
"browse": {
"databaseFilename": "",
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"/home/user/catkin_ws/devel/include/**",
"/opt/ros/melodic/include/**",
...,
"/usr/include/**"
],
"name": "ROS",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++14"
}
],
"version": 4
}
Run Code Online (Sandbox Code Playgroud)
ROS 使用的是c++14 标准,因此指定gnu++14似乎会破坏事情。这是从这个问题推导出来的。
这方面存在一个问题。