I have a driver whose codebase is built for several targets, each with its own Registers.ads that defines the register set for that target. The driver needs to write to a register which may or may not exist in Registers.ads (depending on the configuration).
In C, I would do something like this:
#ifdef REG1 reg_write(REG1, 0x1234); #endif
In Ada though, there is no preprocessor and I can't do this with a regular if statement:
if REG1_EXISTS then reg_write(REG1, 0x1234); end if;
This fails to compile on targets which do not have the register because REG1 is an undefined symbol.
Is there some way to achieve similar behavior to what the C code does? I could theoretically create a HAL with multiple implementations of a write_reg1 function, and select which one gets compiled based on the target, but I'd like to avoid this since there are a lot of registers like this and it would clutter up the code.