Re: NSInteger vs int vs int32_t
Re: NSInteger vs int vs int32_t
- Subject: Re: NSInteger vs int vs int32_t
- From: Greg Parker <email@hidden>
- Date: Mon, 02 Jul 2012 14:36:39 -0700
On Jul 2, 2012, at 1:10 PM, Jens Alfke <email@hidden> wrote:
> I really don't understand the thought behind creating NSInteger. It seems dangerous to have a 'standard' type whose size isn't fixed. It leads to mistakes like storing a file size in an NSUInteger — that's fine in 64-bit, but in a 32-bit app it blows up on large files. I thought we'd already learned this lesson with the old C 'int' type, which has been giving people cross-platform problems since the 1970s.
NSInteger exists to allow APIs to use 64-bit integers in 64-bit mode while preserving source- and binary-compatibility in 32-bit mode. If you start with a pile of 32-bit code that uses `int` and `@encode(int)`, then NSInteger is the correct way to move forward to 64-bit.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden