enum: Add compile-time check for missing strings
If strings are missing (e.g. because the last value of a range changed unknowingly or adding a string was simply forgotten) compilation will now fail. This could be problematic if the upper limit is out of our control (e.g. from a system header like pfkeyv2.h), in which case patches might be required on certain platforms (enforcing at least, and not exactly, the required number of strings might also be an option to compile against older versions of such a header - for internal enums it's obviously better to enforce an exact match, though).
This commit is contained in:
@@ -28,9 +28,6 @@ enum {
|
||||
CONT5,
|
||||
} test_enum_cont;
|
||||
|
||||
/* can't be static */
|
||||
enum_name_t *test_enum_cont_names;
|
||||
|
||||
ENUM_BEGIN(test_enum_cont_names, CONT1, CONT5,
|
||||
"CONT1", "CONT2", "CONT3", "CONT4", "CONT5");
|
||||
ENUM_END(test_enum_cont_names, CONT5);
|
||||
@@ -46,9 +43,6 @@ enum {
|
||||
SPLIT5 = 255,
|
||||
} test_enum_split;
|
||||
|
||||
/* can't be static */
|
||||
enum_name_t *test_enum_split_names;
|
||||
|
||||
ENUM_BEGIN(test_enum_split_names, SPLIT1, SPLIT2,
|
||||
"SPLIT1", "SPLIT2");
|
||||
ENUM_NEXT(test_enum_split_names, SPLIT3, SPLIT4, SPLIT2,
|
||||
|
||||
Reference in New Issue
Block a user