How to print variable in gdb

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:

  • http://sourceware.org/gdb/current/onlinedocs/gdb/Data.html#Data
  • http://sourceware.org/gdb/current/onlinedocs/gdb/Symbols.html#Symbols

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)