Context: embedded systems.
The greater goal is to create a Nim module that is able to determine the ARM architecture of the processor selected by the programmer-user of my module. The module user selects a compiler (gcc or clang) and passes C arguments on the build command line that selects a particular architecture variant.
Step 1: I'm using when defined(clang): ... elif defined(gcc): ... to determine the compiler. I'm not supporting other compilers at this time.
Step 2: My current idea is within the compiler conditional to access compiler-specific c preprocessor definitions to determine the ARM architecture.
Can someone give a suggestion how to do this? Or a better path to obtain this information at compile time?
I've done this:
const ARM_ARCH {.intdefine: "__ARM_ARCH".} = 0
which is a start. But for another compiler, I need to figure out the number when it is embedded in the definition's name, as in __ARM_ARCH_'V'__
let gnuc {.importc: "__GNUC__", nodecl.}: int
echo gnuc
But you cannot access C preprocessor defines at compime time of Nim.