Visual Studio Code Syntax Highlighting shows errors but compiles

北城以北 提交于 2019-12-11 07:43:37

问题


Visual Studio Code highlights all my glut functions as undefined, but compiles flawlessly. How can I get rid of the red underlining, without deactivating the syntax highlighting?

Includes of main.h:

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

I added all paths I could think of to the include path and browse path section in the c_cpp_properties.json file.

{
"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": ""
    }
}

I use Visual Studio Code 1.18 on Ubuntu 16.04 and my build command is:

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

Any ideas?


回答1:


Setting the "C_Cpp.intelliSenseMode": "Tag Parser" in the settings.json does the trick. Thanks a lot @Bob__



来源:https://stackoverflow.com/questions/47429752/visual-studio-code-syntax-highlighting-shows-errors-but-compiles

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