Visual Studio代码语法突出显示错误但编译

时间:2017-11-22 08:15:56

标签: c++ ubuntu visual-studio-code syntax-highlighting glut

Visual Studio Code将我的所有过剩功能强调为未定义,但完美编译。如何在不停用语法高亮的情况下摆脱红色下划线?

highlighting errors

包含main.h

#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glut.h>
#include <math.h>
#include <string>

我将所有可以想到的路径添加到c_cpp_properties.json文件中的包含路径和浏览路径部分。

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

我在Ubuntu 16.04上使用Visual Studio Code 1.18,我的构建命令是:

g++ -g main.cpp -L/usr/lib/x86_64-linux-gnu -lGL -lglut -lGLEW -lGLU

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

"C_Cpp.intelliSenseMode": "Tag Parser"中设置settings.json可以解决问题。非常感谢@Bob __