If enum
is supported by your compiler, then that would be preferred. Failing that, by all means, use #define
. All C++ compilers and modern C compilers should support enum
, but older compilers (particularly ones targeting embedded platforms) may not support enum
.
If you must use #define
make sure to define your constants with parentheses, to avoid preprocessor errors:
#define RED_STATE (1)
#define YELLOW_STATE (2)
#define GREEN_STATE (3)