Re: OSAtomic built-in operations
Re: OSAtomic built-in operations
- Subject: Re: OSAtomic built-in operations
- From: Stefan Werner <email@hidden>
- Date: Sun, 06 May 2012 22:19:15 -0700
On 06.05.2012, at 21:29, Rick Mann wrote:
> I've seen this technique in other places. Why is that better than just casting pointer types? Like this:
>
> int32_t s;
> uint32_t u;
>
> u = *(uint32_t*) &s;
Your code has two variables and make it the programmer's job to keep them in sync. When using a union, you have two names for the same memory address. Also, the union approach is type safe where a C-style pointer cast will allow you to cast anything to a uint32_t* without the compiler warning you about it.
-Stefan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden