Pax, , , X-Macros. , .
#define X_TEST_CASE_LIST \
X(TC_HIW_0019, 0, "TC_HIW_0019") \
X(TC_HIW_0020, 1, "TC_HIW_0020") \
X(TC_HIW_0021, 2, "TC_HIW_0021") \
#define X(id, val, str) id = val,
typedef enum testCaseId {
X_TEST_CASE_LIST
} testCaseId;
#undef X
#define X(id, val, str) str,
char *testCaseDesc[] = {
X_TEST_CASE_LIST
};
#undef X
. , , :
int string_to_enum(const char *in_str) {
if (0)
#define X(id, val, str) else if (0 == strcmp(in_str, str)) return val;
X_TEST_CASE_LIST
#undef X
return -1;
}