This is my first bark here, although I've been lurking for quite some while. Please don't kick me too hard if I'm asking or suggesting the obvious
I'm currently evaluating a number of "Arduino-like" boards, one of the factors under consideration being how accurate the free-running clock is (i.e. mSec drift per hour, sometimes called regulation). In order to put sensible messages at the start of each run I started investigating how to extract the name of the board at compilation time, but could find nothing more useful than Roger and Nick's exchange at Determining which board type is being used? - Programming Questions - Arduino Forum
I know that other people have looked at this in the past, but generally speaking their solution rapidly starts suffering from "bitrot" and there is a risk that it consumes scarce memory space unless very carefully implemented.
I started looking at the overall toolchain, as used both by both the Arduino IDE and alternatives such as the Eclipse CDT. Having determined that there was useful information in the boards.txt etc. files I decided that it was probably viable to parse them using e.g. Perl, but in order to do that I had to use the correct compiler's preprocessor to handle the pinouts file, and eventually decided that the only possible way to handle the job (semi-)automatically was to start off with the platform.txt files.
Then I realised that by adding this to each of the platform.txt files I had a couple of invariant defines which could be expanded in an Arduino program with minimal overhead:
# These can be overridden in platform.local.txt. Be careful to not lose any
# platform-specific options already in the platform.txt file.
compiler.c.extra_flags=-DARDUINO_BOARD_NAME={build.board} "-DARDUINO_BOARD_TEXT={name}"
compiler.c.elf.extra_flags=-DARDUINO_BOARD_NAME={build.board} "-DARDUINO_BOARD_TEXT={name}"
compiler.S.extra_flags=
compiler.cpp.extra_flags=-DARDUINO_BOARD_NAME={build.board} "-DARDUINO_BOARD_TEXT={name}"
compiler.ar.extra_flags=
compiler.objcopy.eep.extra_flags=
compiler.elf2hex.extra_flags=
hence in the .ino or .cpp source file e.g.
 Serial.print("Board: ");
#define STRINGIZE_HELPER(x) #x
#define STRINGIZE(x) STRINGIZE_HELPER(x)
 Serial.print(STRINGIZE(ARDUINO_BOARD_NAME));
 Serial.print(" (");
 Serial.print(STRINGIZE(ARDUINO_BOARD_TEXT));
 Serial.print(") ");
 Serial.print(F_CPU / 1000000.0, 2);
 Serial.println(" MHz");
which results in output like
Board: AVR_UNO (Arduino/Genuino Uno) 16.00 MHz
This should, obviously, go into a platform.local.txt file but the impression I get is that they are the very least poorly documented and I suspect that Eclipse doesn't support them at all.
As I think I've already said, my apologies if I'm stating the obvious and wasting everybody's bandwidth. But at the very least this is something that appears to work efficiently for me.
MarkMLl