typdef'ing a enum and all its enumerators

Discussion in 'C++' started by Dave, Nov 9, 2005.

  1. Dave

    Dave Guest

    I have several enums that are generated by a code generator (and I have
    no control over the code generator), the problem is that the names are
    pretty long

    enum VeryLoooooooongEnumName
    {
    veryLoooooooooong1,
    veryLoooooooooong2,
    ......
    veryLoooooooooong10
    };

    Some old code I'm working on would use a typedef like this:

    typedef VeryLoooooooongEnumName enum ShortName { short1, short2, ... };

    It used to compile using gcc 2.95, but with gcc 3.2 it no longer
    compiles, the error is:

    "multiple types in one declaration"

    So is there a good way to typedef a enum and all its enumerators?

    any help appreciated, thanks in advance
     
    Dave, Nov 9, 2005
    #1
    1. Advertising

  2. Dave

    Ron Natalie Guest

    Dave wrote:
    > Some old code I'm working on would use a typedef like this:
    >
    > typedef VeryLoooooooongEnumName enum ShortName { short1, short2, ... };


    Wrong syntax for typedef. Frankly I don't know why it ever
    wroked for you.

    typedef VeryLooongEnumName ShortName;

    There isn't much you can do about the enumerators other than defining
    a parallel enum. However they're not going to be interchangable.
     
    Ron Natalie, Nov 9, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt Taylor
    Replies:
    6
    Views:
    450
    Victor Bazarov
    Jul 13, 2004
  2. Mark Piffer

    typdef'ing from sig_atomic_t valid?

    Mark Piffer, Apr 22, 2004, in forum: C Programming
    Replies:
    21
    Views:
    1,926
    Dan Pop
    Apr 29, 2004
  3. thunk
    Replies:
    1
    Views:
    359
    thunk
    Mar 30, 2010
  4. thunk
    Replies:
    0
    Views:
    536
    thunk
    Apr 1, 2010
  5. Hal Fulton

    Enumerators and generators

    Hal Fulton, Jul 22, 2010, in forum: Ruby
    Replies:
    7
    Views:
    149
    Roger Pack
    Jul 22, 2010
Loading...

Share This Page