在使用CDT的eclipse中,我想查看结构成员的值,类似于使用“变量视图”查看变量的值的方式。下面是一个非常简单的示例,我希望能够检查test.val1和test.val2的值。该程序运行良好,但我不能使用gdb来查看struct测试。
#include <cstdio>
struct test {
int val1;
int val2;
} test;
int main () {
test.val1 = 3;
test.val2 = test.val1*4;
printf("val1 = %d, val2 = %d\n", test.val1, test.val2);
return 1;
}在我做到这一点后,我的下一个问题将是测试是否有任何区别
extern "C" struct struct test {
int val1;
int val2;
} test;我正在运行: Eclipse IDE for Java Developers版本:使用CDT、CDT SDK和Photran的露娜服务版本2(4.4.2
感谢你在这个可能非常简单的问题上的帮助
保罗
发布于 2015-03-23 15:41:49
在示例代码中,您声明了一个名为test的struct ( type )和一个类型为test的结构变量。GDB似乎对此有问题。
修改您的代码,使类型和变量具有不同的名称(如下所示):
struct Test {
int val1;
int val2;
} test;然后启动调试器。在表达式视图中,添加新的表达式"test“,就是这样。
https://stackoverflow.com/questions/29204922
复制相似问题