Arduino defines some macros so you can use conditional compilation. For example these are from boards.txt:
- use
ARDUINO_AVR_PROMICROif it's specific for board variant - use
DARDUINO_ARCH_AVRARDUINO_ARCH_AVRif it's specific for Arduino with AVR
Also avr-gcc defines macros according to cpu settings (this should be similar for other platforms too):
- use
__AVR_ATmega32U4__if it's specific for only one MCU - use
__AVR__if it's compatible with all AVR based MCUs
And code examples:
#if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__)
// something for ATmegaXX8 family...
#else
// ...
#endif
#ifdef __AVR__
// Code related to AVR
#else
// Code for other architectures
#endif
More about predefined macros in avr-gcc.