I am looking into if_link.h
in the Linux kernel headers and it contains this enum:
enum {
IFLA_UNSPEC,
IFLA_ADDRESS,
IFLA_BROADCAST,
IFLA_IFNAME,
IFLA_MTU,
IFLA_LINK,
IFLA_QDISC,
IFLA_STATS,
IFLA_COST,
#define IFLA_COST IFLA_COST
IFLA_PRIORITY,
#define IFLA_PRIORITY IFLA_PRIORITY
IFLA_MASTER,
#define IFLA_MASTER IFLA_MASTER
....
}
The defines look useless; what is their purpose? And why do only some of the items have defines?
As Matthew Slattery mentioned in another answer, the GCC manual has a section, namely §3.10.5 Self-Referential Macros, which describes the possible uses of such macros.
One possible use is to avoid infinite expansion when a macro expands into a call to itself, but this is a discouraged practice. The other use is to define both preprocessor macros and enums:
So this is basically what M.M said in the above comment.
This seems to be confirmed by this patch:
This macros used in IPv4 protocol for provides the ability to create, remove, or get information about a specific network interface. See man page.