How to tell which core/variant at compile time?

I only have some basic understanding on how this is done. I know there are keywords such as AVR_ATmega_2560 that gets defined before compile time. I can use these with #if defined() to do some conditional compilation. Is there a list of all of these defines for all core/variants? The closest thing I found was the avr_cpunames.h. It defines AVR_CPU_NAME.

What about custom core and variants such as 1284P and bobuino? Do I get some more #define?

Here is what I got from the compilation (IDE 1.6.0):

My own 1284P variant called OSPLV2_4:

-mmcu=atmega1284p -DF_CPU=16000000L -DARDUINO=10600 -DARDUINO_OSPLV2_4 -DARDUINO_ARCH_AVR

Here is 1284P variant Bubino:

-mmcu=atmega1284p -DF_CPU=16000000L -DARDUINO=10600 -DARDUINO_bobuino -DARDUINO_ARCH_AVR

I removed options unrelated to #define. I am guessing by specifying the MCU with -mmcu=atmega1284p, somewhere in the pre-compiling process a def is generated AVR_ATmega1284P. Where exactly?

Here is a post I made a while ago with a list of defines: Best way to determine CPU type at compile time? - #5 by pYro_65 - Libraries - Arduino Forum

Also, there is an exhaustive list of every define in io.h

Here is the path to mine.

(1.6.1 and below)


In 1.6.2 the location is in your user folder:


EDIT: finally found a link online*checkout*/trunk/avr-libc/include/avr/io.h?root=avr-libc&revision=2466&content-type=text%2Fplain

Great! Thanks pYro! I found io.h in the same folder your 1.5.7 has in my 1.6.0. I'm not that fast with IDE updates. So I'm still not sure how these macros are defined. They must be defined with the -mmcu=XXXX. Hoping to find a list.

I also found some standard predef from AVR GCC:

This includes DATE TIME etc.

Here are two different articles with the macro lists (not in source code)

avr libc documentation
Atmel reference

Thank you pYro! Karma! These two references are excellent! I also looked into Atmel's libc ref page but didn't expand every level of the doc and didn't find it myself.