User Tools

Site Tools


mywiki:linux:enum_string

Map Enum to string array or its value array

#define DP_F_FLAG_LIST  \
	DP_F_ENUM_OR_STRING(DP_F_DEREGISTER, 0x00000001, "De-Register"), \
	DP_F_ENUM_OR_STRING(DP_F_FAST_ETH_LAN,   0x00000002, "ETH_LAN"), \
	DP_F_ENUM_OR_STRING(DP_F_FAST_ETH_WAN,   0x00000004, "ETH_WAN"),\
	DP_F_ENUM_OR_STRING(DP_F_FAST_WLAN,      0x00000008, "FAST_WLAN"),\

define an enum

#define DP_F_ENUM_OR_STRING(name,value, short_name) name = value
enum DP_F_FLAG {
	DP_F_FLAG_LIST
};

map enum to string array

#undef DP_F_ENUM_OR_STRING
#define DP_F_ENUM_OR_STRING(name,value, short_name) short_name
char *dp_port_type_str[] = {
	DP_F_FLAG_LIST
};
#undef DP_F_ENUM_OR_STRING

map enum to an value array

#undef DP_F_ENUM_OR_STRING
#define DP_F_ENUM_OR_STRING(name,value, short_name) value
uint32_t dp_port_flag[] = {
	DP_F_FLAG_LIST
};
#undef DP_F_ENUM_OR_STRING
mywiki/linux/enum_string.txt · Last modified: by 127.0.0.1