tags:

views:

1524

answers:

1

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

+5  A: 

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

struct hatstand;
struct hatstand *foo;

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.

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

See also these pages from the GDB manual:

Daniel Cassidy
Nice answer, though the links are 404.
Laurynas Biveinis
Fixed. Can't remember what they were linking to before, but these two links should be helpful :).
Daniel Cassidy