When you declare a enum, the constant values of the enumerator-list automatically increment. E.g.
typedef enum{
TEST0 = 0,
TEST_X, // automatically will be 1
TEST_Y, // ...will be 2
...
}test_t;
Is there a way to make the enumeration constants decrease instead of increase the values? For example with a attribute directive before the type definition or any other solution?
So my desired behavioral:
typedef enum{
TEST0 = 0,
TEST_X, // want to be -1
TEST_Y, // want to be -2
...
}test_t;
The only trick/workaround that comes to my mind would be:
typedef enum{
TEST_LOWEST = -2000,
TEST_X, //-1999
TEST_Y, //-1998
...
TEST0 = 0,
}test_t;
I didn't find an attribute, but maybe there's another solution. But the workaround described above indeed works, too.