typeof and bitfields

Ian Lance Taylor ian@airs.com
Mon Jan 17 21:06:00 GMT 2005


Alexandre Oliva <aoliva@redhat.com> writes:

> On Jan 14, 2005, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> 
> > That is an argument for not returning an int.  It is not an argument
> > for issueing error.  Why not return int_with_2bits?
> 
> Let's see...
> 
> struct x {
>   unsigned int i:2;
> } *p;
> 
> typedef __typeof(p->i) BF;
> 
> struct y {
>   BF j;
>   BF k:14;
> } *q;
> 
> int main() {
>   __typeof(q->j) m = 7;
> }
> 
> What do you expect to get from this piece of code?

What I would argue for is that the typedef is equivalent to
    typedef unsigned char BF;
It's easy to document and easy to understand.  It's not elegant.

Ian



More information about the Gcc mailing list