title: Custom enum type declaration with Arduino
body: <p>I'm having some trouble using a custom enum type in Arduino.</p>
  
  <p>I've read <a href="http://arduino.cc/en/Hacking/BuildProcess" rel="nofollow">elsewhere</a> that using a header file is necessary for custom type declarations, due to Arduino IDE preprocessing. So, I've done that, but I'm still unable to use my custom type. Here's the relevant portions of my code in my main arduino file (beacon.ino)</p>
  
  <pre><code>#include &lt;beacon.h&gt;
  
  State state;
  </code></pre>
  
  <p>And in beacon.h:</p>
  
  <pre><code>typedef enum {
    menu,
    output_on,
    val_edit
  } State;
  </code></pre>
  
  <p>But, when I try to compile, I get the following error:</p>
  
  <pre><code>beacon:20: error: 'State' does not name a type
  </code></pre>
  
  <p>I assume something is wrong about the way I have written or included my header file. But what?</p>