I have a type defined e.g.:
typedef enum {
T1,
T2,
T3,
T4,
T5,
T6,
LAST_IN_ENUM
} type1_t;
then another one using the above type e.g.:
typedef enum {
SUB1 = T1,
SUB2 = T2,
SUB3 = T3,
SUB4 = T4
} type2_t;
I would like to use then some fields of type2_t as input parameters to a function, but referring to its last character from a loop variable value, e.g. for SUB2 and SUB3:
for (i=2; i<4; i++) {
function1(SUBi)
}
What I don't know what the proper syntax is to pass the loop variable value to make it up SUBx (the above for loop syntax doe snot work, obviously).
Thanks a lot in advance if you have the solution.
I tried casting, converting to string, none of them worked.
for( i = SUB2; i < SUB4; i++ )The enum tokens are no more that compile time tokens that represent integer values. They are not runtime variables for accessing or manipulating.C. You could just create an array with the appropriateSUBvalues in the corresponding index location within the array.