From the C Standard (6.6 Constant expressions)
6 An integer constant expression117) shall have integer type and shall
only have operands that are integer constants, enumeration constants,
character constants, sizeof expressions whose results are integer
constants, and floating constants that are the immediate operands of
casts. Cast operators in an integer constant expression shall only
convert arithmetic types to integer types, except as part of an
operand to the sizeof operator.
This expression (uint32_t)&reset_handler
with the cast operator used to initialize an integer is incorrect because the operand of the cast operator does not have an arithmetic type. So it may not be used to initialize integer objects (elements of an integer array) with static storage duration.
So the compiler issues the error
initialiser element is not constant
You could move the array declaration for example from the file scope in main. In this case the array will have automatic storage duration. Nevertheless in any case this casting (uint32_t)&reset_handler
of a function pointer to an integer of the type uint32_t
is wrong.
uintptr_t
> – Almanac