I want to print the value of an enumeration as a #warning
or as a #pragma message
. I use typedef enum
instead of #define
'ing values, as it makes editing easier and allows for typing function parameters and return values.
Reason for printing: The enum
's constant max value must not exceed a certain value, however I can't check the value directly in the code, as its values are auto incremented: typedef enum {a, b, ... az } mytype_t;
. In this example, az must be smaller than [any u_int].
I have tried to stringify the value according to this post, however it works only for #define
'd values. I tried variations on the enum
value, but I could not get the actual value to print, only its name.
Is there a way to print an enum value (or also a const variable) when compiling? Thanks.
EDIT: I use Microchips XC8 compiler (8 bit) and C99.