title: enumerations in C from a c++ perspective
body: <p>I am a C++ programmer and I rarely have to deal with GCC "C". I am currently converting some code from C++ to C for use with the GCC compiler. </p>
  
  <p>In C++ I would use the following source code. Note that I would use a class for scope. </p>
  
  <p><strong>C++ Source</strong> </p>
  
  <pre><code>class Card {
  public:
     enum Suit {
        Diamonds, Hearts, Clubs, Spades
     };
  };
  
  class Weapon {
  public:
     enum WeaponType {
        Rocks, Clubs, Guns
     };
  };
  
  int main () {
   Suit a = Card::Clubs; 
   WeaponType b = Weapon::Clubs
  }
  </code></pre>
  
  <p>In "C" with no classes and no way of differentiation between the two different "clubs" keywords. I get the following error message when trying to compile this </p>
  
  <blockquote>
    <p>error C2365: 'Clubs' : redefinition; previous definition was
    'enumerator'</p>
  </blockquote>
  
  <p><strong>C Source</strong> </p>
  
  <pre><code>enum Suit {
      Diamonds, Hearts, Clubs, Spades
  };
  
  enum WeaponType {
      Rocks, Clubs, Guns
  };
  
  int main () {
   Suit a = Clubs; 
   WeaponType b = Clubs
  }
  </code></pre>
  
  <p>So my questions are </p>
  
  <ul>
  <li>How do I declare two different enum in the same file with the same keyword?</li>
  <li>How do I add scope to the enum so I can assign different variables different enum with the same enum name?</li>
  </ul>