Compilation error
kannappan at tesbv.com
kannappan at tesbv.com
Sun Sep 9 04:04:53 UTC 2007
I dont think its bogus statement. This piece of code is working with
the native host compiler.
Code tries to assign a
Quoting Paul Brook <paul at codesourcery.com>:
> 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
>
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
More information about the uClibc
mailing list