On Feb 2, 2016, at 11:45 , Jens Alfke <email@hidden> wrote:
(To be clear: I understand why this behaves differently, due to the [awful] decision to make NSInteger different sizes in 32-bit vs 64-bit. But at a high level it’s an inconsistent warning, when you have multiple platforms to build for.)
As suggested by Greg Parker on this list a couple of years ago, you can use
%t… (%td, %to, %tu %tx, %tX) for unsigned results %z… (%zd, %zo, %zu %zx, %zX) for signed results
and these work on NS[U]Integer-sized variables on all platforms and architectures that are supported by Apple (without having to cast the parameters).
The ’t’ or ‘z’ controls whether the conversion is unsigned or signed. The ‘d’ or ‘u’ controls whether the parameter is an signed or unsigned variable. This is kinda a distinction without a difference, so, normally, it’s %tu for NSUInteger, and %zd for NSInteger.
These modifiers are documented here:
but using them for this purpose is a trick that is (AFAIK) Greg’s own brain-storm.
|