ntohl and others

Magnus Ahltorp (map@stacken.kth.se)
Thu, 16 Oct 1997 03:04:03 +0200 (MET DST)


Why are ntohl and others defined as macros, and not inlines?

asm/byteorder.h:
#define ntohl(x) ((unsigned long int)(x))
#define ntohs(x) ((unsigned short int)(x))
#define htonl(x) ((unsigned long int)(x))
#define htons(x) ((unsigned short int)(x))

It's difficult to write:

#include <asm/byteorder.h>

int main()
{
unsigned long (*foo)(unsigned long) = htonl;

return (*foo)(17);
}

so, why not:

static inline unsigned long int htonl(unsigned long int x) { return x; }

/Magnus
map@stacken.kth.se