This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Cast to a struct in expressions
- To: Eli Zaretskii <eliz at is dot elta dot co dot il>
- Subject: Re: Cast to a struct in expressions
- From: Daniel Berlin <dan at cgsoftware dot com>
- Date: 27 Apr 2001 11:23:55 -0400
- Cc: gdb at sources dot redhat dot com
- References: <8011-Fri27Apr2001111107+0300-eliz@is.elta.co.il>
"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