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