想从si转到vscode做c/c++开发,但是在最新的1.44.2版本中,发现一个致命缺陷,导致无法使用vscode:
已安装c/c++插件0.27.1
如果一段代码是被某个宏括起来的,这个宏定义在makefile或其他文件中定义,则该宏里面的代码跳转不能成功,代码编辑时也不会自动提示宏控代码中函数或变量。
==========issues #3108:
https://github.com/microsoft/vscode-cpptools/issues/3108
codes as blow:
#define DEBUG_CHECK_RANGE 1;
void test()
{
int count = 0;
#ifdef DEBUG_CHECK_RANGE0 // it's not defined
int local = 0;
local++; // can't go to definition
count++; // can't go to definition
#endif
count++; //it's ok
}
按照开发者的回答是说这是设计本意,只有将每一个macro添加进c_cpp_properity.json里面的defines(默认只有三个系统macro):
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "${default}",
"cStandard": "c11",
"cppStandard": "c++11"
}
],
"version": 4
}
但是对于一个大型工程来说,将每个macro手动输入到脚本中是不现实的,如何才能解决这个问题?