On 17 Aug 2011, at 19:36, Eric Wasylishen wrote:

> Hey,
> 
> I don't like using PRIdPTR because it took me a while to figure out why it 
> works

It's pretty simple: PRI (printf format string), character for int, PTR (pointer 
type).

> (I had to look up that it's a format string for intptr_t, and then check the 
> NSInteger definition to verify that that is also intptr_t…), and PRIdPTR 
> introduces a dependency on how NSInteger is defined everywhere you use it.

NS[U]Integer is defined as a pointer sized integer, anywhere that it is 
defined.  There is no extra dependency: the definition of the type is a 
pointer-sized integer, so the correct format specifier is the relevant one for 
a pointer-sized integer.

> Personally I always cast NSInteger/CGFloat to a c89 type when I need to print 
> them, since it will work on any Foundation implementation. Anyway, we just 
> have to make sure we never have (@"foo: %f", someCGFloat) or  (@"foo: %d", 
> someNSInteger)!

Casting to long long / unsigned long long will also work, as will casting 
CGFloat to double.  

David

--
This email complies with ISO 3103


_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to