• 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: Enum advice please
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enum advice please


  • Subject: Re: Enum advice please
  • From: Greg Parker <email@hidden>
  • Date: Tue, 6 Jan 2009 11:19:45 -0800

On Jan 6, 2009, at 1:53 AM, Graham Cox wrote:
On 5 Jan 2009, at 6:14 pm, Damien Cooke wrote:

typedef enum _DCDBTypes { DCOItemType = 0, DCOCategoryType = 1, DCORegionType = 2

}DCDBTypes;

That said, also try this:

typedef enum
{
	DCOItemType = 0,
	DCOCategoryType = 1,
	DCORegionType = 2
}
DCDBTypes;

I never add in those _blahblah things after enum, I've never understood what they're for. I always typedef enums like this and they always work just fine. (Maybe someone could explain what this other form is all about and whether it matters?)

Start with this pair of declarations. This creates two types, `DCDBTypes` and `enum _DCDBTypes`:


    enum _DCDBTypes {
        DCOItemType = 0,
        DCOCategoryType = 1,
        DCORegionType = 2
    };
    typedef enum _DCDBTypes DCDBTypes;

C allows a contraction of the above. This creates the same two types:

    typedef enum _DCDBTypes {
        DCOItemType = 0,
        DCOCategoryType = 1,
        DCORegionType = 2
    } DCDBTypes;

You can omit the separate enum type:

    typedef enum {
        DCOItemType = 0,
        DCOCategoryType = 1,
        DCORegionType = 2
    } DCDBTypes;

...or even give the two types the "same" name if you want (but not really; one is `enum DCDBTypes` and the other is just `DCDBTypes`):

    typedef enum DCDBTypes {
        DCOItemType = 0,
        DCOCategoryType = 1,
        DCORegionType = 2
    } DCDBTypes;

All of this works the same way with struct types.


-- 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


  • Follow-Ups:
    • Re: Enum advice please
      • From: Quincey Morris <email@hidden>
References: 
 >Enum advice please (From: Damien Cooke <email@hidden>)
 >Re: Enum advice please (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Strange behavior of observeValueForKeyPath:ofObject:change:context:
  • Next by Date: RE: Table sort image question
  • Previous by thread: Re: Enum advice please
  • Next by thread: Re: Enum advice please
  • Index(es):
    • Date
    • Thread