Compilation error
Paul Brook
paul at codesourcery.com
Sun Sep 9 01:00:27 UTC 2007
On Saturday 08 September 2007, Rob Landley wrote:
> On Saturday 08 September 2007 3:32:08 am kannappan at tesbv.com wrote:
> > i have the following piece of code which gives compilation error (like
> > lvalue requried...) may be bug with the compiler
> >
> > uchar *s;
> >
> > *((ushort *)s)++ = val;
>
> You told it to increment the value (which counts as writing to it),
You need to go check C operator precedence rules. Your analysis is completely
bogus.
This is the old cast-as-lvalue extension. It has never been standard C, and
was removed in gcc 4.0. See http://gcc.gnu.org/gcc-4.0/changes.html
> > if i change that to
> > *(ushort *)s = val;
> > s+=2;
> >
> > it works fine.
>
> Well yes. Now you're making it clear what order to do things in.
>
> Since when is +=2 equivalent to ++?
When += 2 is applied to a char * and ++ is applied to a short *.
Paul
More information about the uClibc
mailing list