_Static_assert(SIZE_I_WANT_TO_ASSURE <= AVAILABLE_MEM, "NOT ENOUGH MEMORY!!!");
error: expression in static assertion is not constant
The problem here is that you are trying to compare a "constant" generated during the linking phase of the build, in an expression that requires a compile time constant (that is, something the COMPILER knows during compilation).
#define AVAILABLE_MEM (0Xffff - &__data_end_rom)
The compiler won't know the address of __data_end_rom
, only the linker knows that.
Unfortunately, I don't think there is any way to do this at compile time, make the compiler tell you the data is too large. On the other hand, an additional script reading the binary file (e.g. using size yourprog
in conjunction with a little bit of awk
or something) should be able to provide the relevant information in the makefile
or something similar.