RE: MoreCRC - target of assignment not really an lvalue; this will be a hard error in the future
RE: MoreCRC - target of assignment not really an lvalue; this will be a hard error in the future
- Subject: RE: MoreCRC - target of assignment not really an lvalue; this will be a hard error in the future
- From: "Tim Dorcey" <email@hidden>
- Date: Mon, 14 Jul 2008 21:27:18 -0700
- Importance: Normal
I just ran into that one on a statement like this:
x = *((short *)ptr)++;
I guess it means ((short *)ptr), to which we are going to assign an
incremented value, is not a valid lvalue. A fix is:
x = (short *)ptr; ptr += 2;
Or, probably wiser to make sure "ptr" is aligned on short word boundaries,
and declare it a (short *). FWIW, to write code that makes no assumption
about alignment or host byte-order, you can do:
unsigned char *ptr;
// write short x in network byte order (big endian)
*ptr++ = (unsigned char) (x >> 8);
*ptr++ = (unsigned char) x;
// read short x in network byte order
x = *ptr++;
x = (x << 8) | *ptr++;
ptr needs to be unsigned or else *ptr will be sign extended into high byte
of x. This works correctly regardless of byte-order on the host.
Tim
> -----Original Message-----
> From: macnetworkprog-bounces+tim=email@hidden
> [mailto:macnetworkprog-bounces+tim=email@hidden]
> On Behalf
> Of Mike
> Sent: Monday, July 14, 2008 6:41 PM
> To: email@hidden
> Subject: MoreCRC - target of assignment not really an lvalue;
> this will
> be a hard error in the future
>
>
> Does anyone know how to turn off this error in XCode 2.5 or
> fix the code
> so that it doesn't occur?
>
> Thanks,
>
> Mike
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Macnetworkprog mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden