im not trying to "do" anything in the preprocessor, I justcwant to use it to its max to set up compile time constants so that my general purpose code has everything in place.
almost all of what it does is hw register specific and thus I want to make sure the correct registers for the mcu are in place prior to compile. an example...pseudocode, im on a tablet and correct syntax is a pain..
objective: register the interrupt n
set bit in ctrl register to allow ints for the block that maps to pcint n
dtetermine mask register that maps pcint n
set bit in mask to allow int n
pseudocode for 328, tiny48, 2560 etc etc..any mcu using PCICR
PCICR |=_BV(PCIEx) // x depends on n, usually int.truncated n/8
PCMSKy |= _BV(n) // y dpends also on n, usually n%8
savedPort=PORTz // z depends on mcu and n
pseudocode for tiny24,44,2313 etc etc or any mcu using GIMSK
GIMSK |=_BV(PCIEx) // x depends on n, usually int.truncated n/8
PCMSKy |= _BV(n) // y dpends also on n, usually n%8 may well be different for this mcu from y above etc
savedPort=PORTz // different z per mcu of course and not same as above..
at its most abstract, I want
%REG |= _BV(x) // or bv on PCIE%x, I dont mind
etc where im using % as a conceptual tag for a replaced parameter
providing that my header defines the appropriate macros or functions for the mcu specific pcint2xxx routines and sets the %x y and z for the mcu, then that one piece of code will compile and work for whatever mcu is selected.
I know thats a very loose theoretcial explanation, but I hate typing on my tablet, and im sure you know where im coming from.
To me, that seems to be a proper, sensible and fairly common use of the preprocessor...its what some arduino cores do for things like digitalPinToPCICR, digitalPinToPCMSKBit etc..which do pretty much what I want to do, but NOT for arduino digital pins, for PCINT numbers. there are no corresponding GIMSK ....why would there be, arduino doesnt make any tiny45 or 2313 boards..but I do and I want a single library that will compile for all my targets. is it such a big ask...im 95% there already, I was just fitting in these lsst few edge cases when i had my idea about automatically pulling in mcuxxx.h files...
I think I need to take my php python hat off where everything is included at runtime and be tweaked within an inch of its life or even have parameters edited in and then eval'd...dont cringe!