Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.
We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.
Thank you for your understanding.
void function(void) { printf("test"); } const uint16_t addr = (uint16_t)function;
Why MDK(ARM) report an error: initializer element is not a compile-time constant ?
I tried to compile this code in a minimal project, and I changed the function name and variable name, the problem remains;
But
const uint32_t addr = (uint32_t)function;
can be compiled correctly!
Maybe because it makes not really sense to store the (non constant) address of a function in a 16 or 32 bit integer variable?
My MCU flash is only 64K. I want to create a very large list of callback functions. If I use 32-bit address, obviously the upper 16 bits are meaningless.