vscode 的 c/c++ 语义解析屏蔽他不认识的关键字
有一些比较愚蠢的编译器,例如 TI 的 DSP 编译链,既没有很好的 vscode 支持,又有一些奇葩非标准关键字。
我们使用 vscode 对这些项目进行编辑时就会严重阻碍语义解析。我过去解决过,今天又忘了。
一个好的办法是在 C/C++ 插件的 define
中将这些关键字作为空的 define,例如以下是对 interrupt
关键字的实践。需要增加结尾的等号才能实现空定义。
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${default}",
"${workspaceFolder}/**"
],
"defines": [
"__GNUC__",
"_DEBUG",
"UNICODE",
"_UNICODE",
"interrupt="
],
"compilerPath": "C:/111_APPS/MSYS2/mingw64/bin/gcc.exe",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-arm",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}