gdb support for unnamed union/structure fields

Amit Choudhary amit2030@yahoo.com
Wed Oct 11 05:54:00 GMT 2006



--- Mathew Spencer <mvyacc1029@yahoo.com> wrote:

> Yes, the code was compiled with "-g" option, but when
> I dump foo structure in gdb, gdb only prints values of
> "int a; int d", but not "int b; int c" which happen to
> be inside unnamed structure.
> 

It prints for me. My gdb version is 

GNU gdb Red Hat Linux (6.3.0.0-1.122rh)

#include<stdio.h>

typedef struct {
       int a;
       struct {
         int b;
         int c;
       };
       int d;
 } foo;

main()
{
foo amit;
amit.a = 10;
printf("amit.a = %d\n", amit.a);
printf("amit.b = %d\n", amit.b);
}


(gdb) p amit
$1 = {a = 10, {b = -1074995640, c = 134513646}, d = 1279667776}


Regards,
Amit Choudhary


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Gcc-help mailing list