title: C++ packing a typedef enum
body: <pre><code>typedef enum BeNeLux
  {
     BELGIUM,
     NETHERLANDS,
     LUXEMBURG
  } _ASSOCIATIONS_ BeNeLux;
  </code></pre>
  
  <p>When I try to compile this with C++ Compiler, I am getting errors, but it seems to work fine with a C compiler. So here's the question. Is it possible to pack an enum in C++, or can someone see why I would get the error?</p>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>"semicolon missing after declaration of BeNeLux". </p>
  </blockquote>
  
  <p>I know, after checking and rechecking, that there definitely is a semicolon there, and in any places required in the rest of the code.</p>
  
  <p>Addendum:</p>
  
  <p><code>_PACKAGE_</code> was just an example. I am renaming it.</p>
  
  <p><code>_ASSOCIATIONS_</code> is not a type of BeNeLux:</p>
  
  <p><code>#define _ASSOCIATIONS_ __attribute__((packed))</code></p>
  
  <p>The code is iffed, but only to make sure it is GNU C/C++.</p>
  
  <pre><code>#if defined (__GNUC__) 
  #define _ASSOCIATIONS_ __attribute__((packed))
  #else
  #define _ASSOCIATIONS_
  </code></pre>
  
  <p>Would this cause problems? I thought (<strong>GNUC</strong>) worked for both C and C++<br /></p>
  
  <p>Addendum 2:</p>
  
  <p>I even tried </p>
  
  <pre><code>#ifdef __cplusplus
  extern "C" {
  #endif
  
      typedef enum BeNeLux
      {
         BELGIUM,
         NETHERLANDS,
         LUXEMBURG
      } _ASSOCIATIONS_ BeNeLux;
  
  #ifdef __cplusplus
  }
  #endif
  </code></pre>
  
  <p>No joy. Anyone?</p>
  
  <p>Note: -fshort-enums is not a possibility; looking for a programmatic solution.</p>