This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: generalized lvalues -- patch outline


> The average C programmer would not have thought to use this extension
> unless they just decided one day to try it or they actually read the
> gcc documentation (which I know almost nobody does).

I disagree: *((int *)p)++ was accepted by virtually all the good old 
compilers: GCC 2.x, Microsoft, Borland, Watcom.  This is a natural idiom when 
you're manipulating images with different color depths:

  char *p = bitmap->data;

  switch (color_depth)
  {
? ? case 8:
? ?   *p++ = c;
? ? ? break;

    case 15:
? ? case 16:
? ?   *((short *)p)++ = c;
      break;

? ? case 32:
? ?   *((int *)p)++ = c;
      break;
? ?} 

Of course, nowadays everything is 32-bit so... :-)

And

char *a1 = (char*)a;
a1 += sizeof(int)/sizeof(char);
a = (typeof(a))(a1);

is plain ugly.

-- 
Eric Botcazou


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