On Mon, Dec 15, 2008 at 2:35 PM, Stuart Malin <stu...@zhameesha.com> wrote: > I am trying to be 32/64 bit "clean" in some new code that I am writing. When > I declare some integer values, say for named option values as shown here, > what is the type that the compiler assigns to these values? > > enum { > SomeOptionValue = 1, > AnotherOptionValue = 2, > };
>From reading the summaries in a google search for "c enum type", it would appear that they are of type int. > Separately, from a space efficiency perspective, would it be better in the > case of having a small set of option values to force the type to be an > unsigned int? That is, if I have a method that takes such an option, which > of the following method signatures is nowadays preferred? > > - (void) someMethodWithOption:(unsigned int)optionValue; > > - (void) someMethodWithOption:(NSInteger)optionValue; >From a space efficiency perspective it's completely irrelevant. Larger parameters take up at worst very little space, and may take up none at all depending on your architecture's alignment and minimum size policies. If you follow Apple's lead on this, they use typedefs to NSInteger for enumerators. Personally I prefer to use the enum itself, or a typedef of it. This provides additional information about the type to the compiler and the debugger which allow the former to produce more useful diagnostics and the latter to produce more useful output. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com