Hello,
I want to use the #error directive to limit the size of a statically allocated array during compilation (it must not exceed a certain limit, and I want to fail compilation, not startup, if it is too large), but I can only work with constant expressions, of course. Is there a way to do this...?
Thanks.
Why?
Can't you just do:
#define ARRAY_SIZE my_type my_array[ARRAY_SIZE];
I don't want to limit the number of elements but the amount of RAM the array consumes - and to enforce that during compilation.
sizeof would need to be used on structures but that is not available to the pre-processor.
I've done it before with a custom written, post link executable/map verifier.
View all questions in Keil forum