This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Cast to a struct in expressions


"Eli Zaretskii" <eliz@is.elta.co.il> writes:

> Should the following work?
> 
>   (gdb) p/x *(struct {long foo; unsigned bar;} *)foobar
> 
> It doesn't seem to work for me; GDB complains thusly:
Correct.

> 
>   A parse error in expression, near `long foo; unsigned bar} *)foobar
> 
> Seems like the parser chokes on the struct declaration?
Yes.
>   Am I missing something?
Yes, I think. The parser only handles expressions, nothing more.
This is why it's c-exp.y, and not c.y.
:)

If you have a real struct already defined, of course, and di

p/x *(sturct foostruct *)foobar

then *that* should work.
--dan

-- 
"I couldn't find the remote control to the remote control.
"-Steven Wright


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]