What board?

When you try to write portable code it is useful to know what board you're compiling on. Is there some way I have not seen to distinguish at compiletime the current board, e.g. a #define BOARD = UNO / MEGA / NANO ...?


A portable code would not specify a board. That is the whole point of the hardware specializations of the IDE. There is a board selection available in the menu system of the IDE. Do you have a special reason to specify the board in the code itself?

If you want to adapt your code to different boards, you can do it by creating your own #define's, #if's and #ifdef's. Actually you seem to have the idea already, above.

Yes, there is a set of defines you can check for to see what board you're on. Look at pins_arduino.h. I think it makes use of some. Look around other places in the core.