Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GCC 4.0 "C" question



On Oct 31, 2005, at 11:43 AM, Mark Dawson wrote:

I'm taking on some older code, and I'm getting this warning: "warning: target of assignment not really an lvalue; this will be a hard error in the future"

for the following line:

*((uint32_t*)dst)++ = *((uint32_t*)src)++;

The real problem is with ((uint32_t*)dst)++ (and with ((uint32_t*)src) ++). The reason is that (uint32_t*)dst is not a valid lvalue; however, *(uint32_t*)dst is.



Why is this code going to be an error in the future?

For now, I just replaced it with:
    uint32_t *aligned32Src, *aligned32Dst;
    aligned32Src            = (uint32_t *)src;
    aligned32Dst            = (uint32_t *)dst;
     *aligned32Dst++    = *aligned32Src++;


How about *(uint32_t*)dst = *(uint32_t*)src; dst = (typeof(dst))((uint32_t*)dst + 1); src = (typeof(src))((uint32_t*)src + 1);

Where you would probably want to use the actual type of dst and src in the case since typeof is a gcc extension.

- Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden

References: 
 >GCC 4.0 "C" question (From: Mark Dawson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.