Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use both anonymous enum and define macros for constants? [duplicate]

Why netinet/in.h defines constants this way?

enum
{
    IPPROTO_IP = 0,    
#define IPPROTO_IP          IPPROTO_IP
    IPPROTO_HOPOPTS = 0,   
#define IPPROTO_HOPOPTS     IPPROTO_HOPOPTS
    IPPROTO_ICMP = 1,      
#define IPPROTO_ICMP        IPPROTO_ICMP
    IPPROTO_IGMP = 2,      
    ...
};
like image 735
jackhab Avatar asked Oct 15 '25 21:10

jackhab


1 Answers

There's probably other code relying on #ifdef IPPROTO_IP etc.

like image 63
emlai Avatar answered Oct 18 '25 11:10

emlai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!