如何打印<不完整的类型>gdb 中的变量 [英] How to print <incomplete type> variable in gdb

查看:16
本文介绍了如何打印<不完整的类型>gdb 中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时 gdb 会为某些类型的变量打印不完整类型".这是什么意思?我们如何才能看到这个价值?

Sometimes gdb prints "incomplete type" for some type of variables. What does this mean and how can we see that value?

推荐答案

表示该变量的类型指定不完整​​.例如:

It means that the type of that variable has been incompletely specified. For example:

struct hatstand;
struct hatstand *foo;

GDB 知道 foo 是一个指向 hatstand 结构的指针,但该结构的成员尚未定义.因此,不完整类型".

GDB knows that foo is a pointer to a hatstand structure, but the members of that structure haven't been defined. Hence, "incomplete type".

要打印该值,您可以将其转换为兼容的类型.

To print the value, you can cast it to a compatible type.

例如,如果你知道 foo 实际上是一个指向 lampshade 结构的指针:

For example, if you know that foo is really a pointer to a lampshade structure:

print (struct lampshade *)foo

或者,您可以将其打印为通用指针,或者将其视为整数:

Or, you could print it as a generic pointer, or treat it as if it were an integer:

print (void *)foo
print (int)foo

另请参阅 GDB 手册中的这些页面:

See also these pages from the GDB manual:

这篇关于如何打印<不完整的类型>gdb 中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆