Consider the following function
CGSize CGSizeIntegral(CGSize size)
{
return CGSizeMake(ceilf(size.width), ceilf(size.height));
}
CGSi
To determine if you are compiling for 64-bit, use __LP64__
:
#if __LP64__
return CGSizeMake(ceil(size.width), ceil(size.height));
#else
return CGSizeMake(ceilf(size.width), ceilf(size.height));
#endif
__LP64__
stands for "longs and pointers are 64-bit" and is architecture-neutral.
According to your transition guide it applies for iOS as well:
The compiler defines the
__LP64__
macro when compiling for the 64-bit runtime.
However, the preferred way to handle your use case is to use CGFLOAT_IS_DOUBLE
. There is no guarantee that __LP64__
will always mean the CGFloat
is a double, but it would be guaranteed with CGFLOAT_IS_DOUBLE
.
#if CGFLOAT_IS_DOUBLE
return CGSizeMake(ceil(size.width), ceil(size.height));
#else
return CGSizeMake(ceilf(size.width), ceilf(size.height));
#endif