Arduino magic? Compiler option? #ifdef #include #endif

terraduino:
I added this for Arduino IDE not for PlatformIO. :wink:

The point @westfw was trying to make is that the Arduino IDE automatically includes such #defines when building.

If you had used the correct identifier (AVR_ATmega328P) in your condition it would have worked as @westfw described...

#if defined( __AVR_ATmega328P__ ) || defined( __AVR_ATmega328__ )