user600: I'm trying to find a way to set a -D compiler option from within the boards.txt file. Basically set a #define for use in code. There are already some special ones like board.vid but is there a generic way to do it?
Somehow the Teensy add-on adds a little magic that allows the IDE to recognize options like:
.board.define0=-DHELLOWORLD
.board.option0=-DHELLOWORLD
In other words, add the -DHELLOWORD (#define HELLOWORLD) to the command line for GCC.
BUT, I can't get this to work without the Teensy add-on installed.
Is there a way to do this with the stock IDE?

user60: Yes, it is possible in the 1.5.+ IDE. while not possible in the 1.0.+ and earlier.
Hardware-specification refers to both the boards.txt and platform.txt files.
in short the boards.txt file specifies...
uno.build.f_cpu=16000000L

and the platform.txt uses in the compile commands such as ...
 -DF_CPU={build.f_cpu}

You can your own. There is already a "build.extra_flags=" that some of the USB devices use to add their own FLAGs conditionally on the board type.

600: <p>I'm trying to find a way to set a -D compiler option from within the boards.txt file. Basically set a #define for use in code. There are already some special ones like board.vid but is there a generic way to do it?</p>

<p>Somehow the Teensy add-on adds a little magic that allows the IDE to recognize options like:
.board.define0=-DHELLOWORLD
.board.option0=-DHELLOWORLD</p>

<p>In other words, add the -DHELLOWORD (#define HELLOWORLD) to the command line for GCC.</p>

<p>BUT, I can't get this to work without the Teensy add-on installed.</p>

<p>Is there a way to do this with the stock IDE?</p>
 60: <p>Yes, it is possible in the 1.5.+ IDE. while not possible in the 1.0.+ and earlier.</p>

<p><a href="https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification" rel="nofollow">Hardware-specification</a> refers to both the boards.txt and platform.txt files.</p>

<p>in short the boards.txt file specifies...</p>

<pre><code>uno.build.f_cpu=16000000L
</code></pre>

<p>and the platform.txt uses in the compile commands such as ...</p>

<pre><code> -DF_CPU={build.f_cpu}
</code></pre>

<p>You can your own. There is already a "build.extra_flags=" that some of the USB devices use to add their own FLAGs conditionally on the board type.</p>
