EclipseCDTisconst检查
我有一个简单的指针.c文件:EclipseCDTisconst检查,eclipse,eclipse-cdt,Eclipse,Eclipse Cdt,我有一个简单的指针.c文件: #include<stdio.h> // Pointer To Constant const int* ptrToConst ; //Constant Pointer int* const ConstPtr ; 输出为: Variable Name: ptrToConst Is Constant: true Variable Name: ConstPtr Is Constant: false 根据输出,指向常量的第一个变量被解析为常量,而另一
#include<stdio.h>
// Pointer To Constant
const int* ptrToConst ;
//Constant Pointer
int* const ConstPtr ;
输出为:
Variable Name: ptrToConst
Is Constant: true
Variable Name: ConstPtr
Is Constant: false
根据输出,指向常量的第一个变量被解析为常量,而另一个变量则不是常量指针。我不明白这种行为,为什么会这样?CDT对指针变量的理解是否不同?根据我的理解,输出应该正好相反
在调试时检查第二种情况下的变量d详细信息:
自(见)
声明指向常量整数的指针(可修改)和const int*ptrtocont
声明一个指向整数(可修改)的contant指针int*const ConstPtr
sd.getDeclSpecifier().isConst()
返回false
因此,在第二种情况下,
常量
修饰符可以在的抽象语法树中找到(正如您自己发现的那样)。在循环的行中设置一个断点,并找出在抽象语法树中的位置(ast
)关于第二个案例的const
修饰符的信息是hold。我试过了,但没有得到这样的信息。我们到底可以在哪里调查呢?已经添加了它的截图,请检查。非常感谢。您查看过声明器>[0]>pointerOps吗?刚刚检查过,它正确地位于pointerOps之下!!谢谢!你能解释一下原因吗?
Variable Name: ptrToConst
Is Constant: true
Variable Name: ConstPtr
Is Constant: false