• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Xcode-users Digest, Vol 2, Issue 621
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode-users Digest, Vol 2, Issue 621


  • Subject: Re: Xcode-users Digest, Vol 2, Issue 621
  • From: Wim Lewis <email@hidden>
  • Date: Mon, 31 Oct 2005 14:44:07 -0800

On 31 Oct, 2005, at 2:04 PM, George Warner wrote:
On Mon, 31 Oct 2005, Mark Dawson <email@hidden> 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)++;

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

Just use:

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

The typecasting has president over the post-increment operator. It will "do the right thing". (And not cause the warning ;-).

No, that'll do something else --- it would be equivalent to
*(uint32_t *)(dst++) = *(uint32_t*)(src++);
which will leave dst and src with different values after the increments than if they'd been cast to uint32, unless they happened to already be pointing to a type with the same width as a uint32.


As Steve Checkoway points out the problem is not that *(type *)foo is being used as an lvalue in the assignment, but that ((type *)foo) is being used as an lvalue by the ++ operator. The warning message is a little misleading.



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Xcode-users Digest, Vol 2, Issue 621 (From: George Warner <email@hidden>)

  • Prev by Date: Re: Xcode-users Digest, Vol 2, Issue 621
  • Next by Date: Re: Creating Custom Project Templates
  • Previous by thread: Re: Xcode-users Digest, Vol 2, Issue 621
  • Next by thread: Creating dynamic and static libs from one target
  • Index(es):
    • Date
    • Thread