Checking uC model inside of a program?

Hello,
is there a way of checking what microcontroller model is being used inside of a program? It would help for doing quick compatibility checks to avoid problems when running software on a different board.
Thanks in advance,
Digitalis

I found this:

which appears to be able to tell the board at runtime. See the discussion of the last post at the bottom of the page found here:

Here's a few processor definitions that I dug up in "\Arduino\libraries\Firmata\Boards.h":-

__AVR_ATmega328P__ : UNO, Arduino Duemilanove, Diecimila, and NG
__AVR_ATmega168__ : Arduino Duemilanove, Diecimila, and NG
__AVR_ATmega8__ : old Arduinos
__AVR_ATmega1280__ : Mega
__AVR_ATmega2560__ : Mega
__SAM3X8E__ : DUE
__AVR_AT90USB162__ : Teensy 1.0
if defined(__AVR_ATmega32U4__) && defined(CORE_TEENSY) : Teensy 2.0
if defined(__MK20DX128__) || defined(__MK20DX256__) : Teensy 3.0 and 3.1
if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) : Teensy++ 1.0 and 2.0
__AVR_ATmega32U4__ : Leonardo
ARDUINO_LINUX : Intel Galileo
if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)|| defined(__AVR_ATmega1284P__) : Sanguino
__AVR_ATmega645__ : Illuminato

Edit: And in "\Arduino\hardware\arduino\avr\bootloaders\stk500v2\avr_cpunames.h" there's another fairly comprehensive list. (Much bigger than the one above.)

N.B. I tried the "BOARD_UNO" define from the "ArduinoBoardManager.h" link, and it fails to identify my UNO.

Here is a working example with it: Arduino Playground - ShowInfo

I think it is much more usefully done at compile-time rather than run-time. It's not like Windows where you put an executable on a web site, and need to check if the user has a scanner, or something like that.

For different boards, you need to compile "for the board" or the wrong instructions will be used. Thus, you check at compile-time if certain features are present.

I agree with Nick. I never thought that someone would do it different.
Reply #2 and my Reply #3 use the AVR_ATmega328P defines. That is done at compile time.