Board Dependent Compilation

Hi All.

Wondering if the Arduino IDE makes available to the C pre-processor the selection made under "Tools --> Board". That way it could be used in board-dependent conditional compilation statements.

If so, where do you find the list of values?

Thanks.

Greg

Wondering if the Arduino IDE makes available to the C pre-processor the selection made under "Tools --> Board".

Of course it does.

If so, where do you find the list of values?

Look at pins_arduino.h for how it does it.

PaulS:
Look at pins_arduino.h for how it does it.

Well, I'm sure it's in there. But, I'm not smart enough to figure it out. All I want to know is whether the board is a Sparkfun Thing Dev

Or an Adafruit ESP8266 Huzzah Feather

Guidance appreciated.

gfvalvo:
If so, where do you find the list of values?

Thanks.

Greg

boards.txt, the build.board field. Some examples:

uno.build.board=AVR_UNO
diecimila.build.board=AVR_DUEMILANOVE
pro.build.board=AVR_PRO

The command line appends ARDUINO_ to them, so the preprocessor macro for the Uno board will be ARDUINO_AVR_UNO.

gfvalvo:
Well, I'm sure it's in there. But, I'm not smart enough to figure it out. All I want to know is whether the board is a Sparkfun Thing Dev
https://www.sparkfun.com/products/13711

Or an Adafruit ESP8266 Huzzah Feather
Adafruit Feather HUZZAH with ESP8266 - Loose Headers : ID 2821 : $16.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Guidance appreciated.

Stuff you download from the board manager will be in a different place, not the installation directory. On Windows, my ESP boards went to: %LOCALAPPDATA%\Arduino15\packages\esp8266

The macro for the HUZZAH board is ARDUINO_ESP8266_ESP12. I don't know about the Sparkfun board, you'll have to find that boards.txt file on your own.

Alternatively, you can turn on verbose compilation and look through the command lines for this:

"C:\Users\MDowd\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=4000000UL -DARDUINO=10612 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\Users\MDowd\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.14\cores\arduino" "-IC:\Users\MDowd\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.14\variants\eightanaloginputs" "C:\Users\MDowd\AppData\Local\Temp\arduino_build_787780\sketch\test.ino.cpp" -o "nul"

Thanks Ninja, not sure why it needs to be so convoluted...

The SparkFun Thing Dev macro is ARDUINO_ESP8266_THING_DEV.

gfvalvo:
not sure why it needs to be so convoluted...

I agree that appending ARDUINO_ to it makes things a bit more confusing than necessary. I guess they did that to avoid conflicts with other macros. However, in this case Arduino did a good job of documenting the feature: