• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSInteger vs int vs int32_t
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSInteger vs int vs int32_t


  • Subject: Re: NSInteger vs int vs int32_t
  • From: Chris Hanson <email@hidden>
  • Date: Mon, 02 Jul 2012 12:06:50 -0700

NSInteger and NSUInteger also have the advantage of having the same @encode() on 32-bit and 64-bit, which can be important for binary compatibility of archives and IPC between architectures, depending on how you do it.

  -- Chris

On Jul 2, 2012, at 8:58 AM, Jens Alfke <email@hidden> wrote:

>
> On Jul 2, 2012, at 4:24 AM, Andreas Grosam wrote:
>
>> Anyway, is it preferable to use always Cocoa macros (NSInteger, NSUInteger, etc.) for an Objective-C API - or may/should I use int, unsigned int, or maybe int32_t, uint32_t, etc. when it seems more appropriate?
>
> Sure, use smaller types if it's appropriate. But consider first whether the size savings are worthwhile (keeping in mind C's data alignment and struct packing rules.)
>
> I'm not a big fan of NSInteger/NSUInteger because they have the very annoying property of being different sizes in 32 vs 64 bit builds (one consequence is that there is no '%' formatting specifier that works correctly with them.) But if your API represents things like collection sizes or array indexes, it's best to play along and use those types.
>
> ―Jens
> _______________________________________________
>
> 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

_______________________________________________

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


References: 
 >NSInteger vs int vs int32_t (From: Andreas Grosam <email@hidden>)
 >Re: NSInteger vs int vs int32_t (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Equation style display
  • Next by Date: Re: NSDocument last document loading
  • Previous by thread: Re: NSInteger vs int vs int32_t
  • Next by thread: Re: NSInteger vs int vs int32_t
  • Index(es):
    • Date
    • Thread