user67594: I'm building an arduino program on linux, using the following Makefile:
ARDUINO_DIR = /usr/share/arduino
BOARD_TAG = uno
ARDUINO_PORT = /dev/ttyAMA0
ARDUINO_LIBS = Wire
include /usr/share/arduino/Arduino.mk

Currently all of my code is spread among a dozen header files and a single .ino file - it gets compiled and it runs properly when flashed. I know that's not correct though and I'm trying to split my code into the proper structure of source and header files but when I do and try to build it I get the following output:
In file included from gear.c:1:0:
gear.h:19:1: error: unknown type name ‘byte’
 byte GEAR = 3;
 ^

Which leads me to believe that the source file is getting compiled separately and does not know what a byte is, which is supposedly defined somewhere within the arduino library.
What's the proper way to build my project with source files?

user7508: First of all, I recommend you write in C++ (file extension .cpp) rather
than in plain C (files in .c). The reason is that the Arduino
programming environment is based on C++, some of the libraries are
C++-only, and your main .ino file will be compiled as C++ source. Mixing
this with C is possible, using some extern "C" declarations, but it is
probably more hassle that it's worth.
Now, to answer your actual question, just add thsi near the top of your
source files:
#include <Arduino.h>

This includes the type definitions specific to the Arduino environment,
together with the core API. This include is added automatically to any
file ending in .ino, but you have to add it explicitly to your .cpp
files.

67594: <p>I'm building an arduino program on linux, using the following <code>Makefile</code>:</p>
<pre><code>ARDUINO_DIR = /usr/share/arduino
BOARD_TAG = uno
ARDUINO_PORT = /dev/ttyAMA0
ARDUINO_LIBS = Wire
include /usr/share/arduino/Arduino.mk
</code></pre>
<p>Currently all of my code is spread among a dozen header files and a single <code>.ino</code> file - it gets compiled and it runs properly when flashed. I know that's not correct though and I'm trying to split my code into the proper structure of source and header files but when I do and try to build it I get the following output:</p>
<pre><code>In file included from gear.c:1:0:
gear.h:19:1: error: unknown type name ‘byte’
 byte GEAR = 3;
 ^
</code></pre>
<p>Which leads me to believe that the source file is getting compiled separately and does not know what a <code>byte</code> is, which is supposedly defined somewhere within the arduino library.</p>
<p>What's the proper way to build my project with source files?</p>
 7508: <p>First of all, I recommend you write in C++ (file extension .cpp) rather
than in plain C (files in .c). The reason is that the Arduino
programming environment is based on C++, some of the libraries are
C++-only, and your main .ino file will be compiled as C++ source. Mixing
this with C is possible, using some <code>extern &quot;C&quot;</code> declarations, but it is
probably more hassle that it's worth.</p>
<p>Now, to answer your actual question, just add thsi near the top of your
source files:</p>
<pre class="lang-cpp prettyprint-override"><code>#include &lt;Arduino.h&gt;
</code></pre>
<p>This includes the type definitions specific to the Arduino environment,
together with the core API. This include is added automatically to any
file ending in .ino, but you have to add it explicitly to your .cpp
files.</p>
