I was browsing a C source file (4cpp_lexer_types.h) in https://4coder.handmade.network/static/media/file/4coder/fcpp-lexer-1.1.zip and found the following code and cannot understand the use/benefit of this.
#define ENUM(type,name) typedef type name; enum name##_
ENUM(uint32_t, Cpp_Token_Type){
CPP_TOKEN_JUNK = 0,
CPP_TOKEN_COMMENT = 1,
.
.
.
};
From the #define I can deduce that that post preprocessing, code would look like this.
typedef uint32_t Cpp_Token_Type; enum Cpp_Token_Type_{
CPP_TOKEN_JUNK = 0,
CPP_TOKEN_COMMENT = 1,
.
.
.
};
Why not simply typedef the enum like the following?
typedef enum {
CPP_TOKEN_JUNK = 0,
CPP_TOKEN_COMMENT = 1,
.
.
.
}Cpp_Token_Type;
I both cases the usage will be the same:
Cpp_Token_Type t = CPP_TOKEN_JUNK;
So my question is why do this, is this some standard practice that aims for some specific result?