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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com