Compiling my iOS application's code for arm64 I faced an interesting problem, related to different basic types for custom Foundation types. Say I want to printf (or stringWithFormat) a number declared as NSUInteger
[NSString stringWithFormat:@"%u", _depth,
This will produce a warning compiling for arm64, because NSUInteger declared as unsigned long for arm64. Therefore, I should replace "%u" with "%lu", but now this becomes invalid when compiling for armv7(s) architecture, because for 32-bit architectures NSUInteger declared as unsigned int. I'm aware that warning says "NSUInteger should not be used as format argument", so lets proceed to floats:
typedef CGFLOAT_TYPE CGFloat;
on 64-bit CGFLOAT_TYPE is double, while on 32-bit it is float. Therefore, doing something like this:
- (void)foo:(CGFloat)value;
and then
[self foo:10.0f];
[self foo:10.0];
Will still produce a warning when compiling for two architectures. On 32-bit architecture second call is not correct (conversion from double to float), on 64-bt architecture, the first one converts float to double (which is ok, but still not good).
Would love to hear your thoughts on this problem.