Tuesday, February 3, 2015

Implicit conversion loses integer precision: 'NSUInteger' (aka 'unsigned long') to 'u_int32_t' (aka 'unsigned int')

After adjusting our app to support 64bit, we got a lot of warnings like this:
Implicit conversion loses integer precision: 'NSUInteger' (aka 'unsigned long') to 'u_int32_t' (aka 'unsigned int')


http://stackoverflow.com/questions/25954180/warning-implicit-conversion-loses-integer-precision-in-xcode-6
On 64 bit systems NSUInteger and NSInteger are 64-bits, but int is 32-bit.  It's best to avoid int.
NSArray count is NSUInteger
NSIndexPath row is NSInteger



http://stackoverflow.com/questions/19372312/objective-c-implicit-conversion-loses-integer-precision-nsuinteger
You can safely suppress some warnings with a cast using (uint32_t) as long as you know the int your are casting will alwasy be under 2^32-1.

No comments:

Post a Comment