这个问题也困扰了我好久,最后在stack overflow上面看到了答案
On linux gethostbyname() is declared in glibc/resolv/netdb.h (see here), pseudo defined via macros in inet/gethstbynm.c (see here), and finally defined in nss/getXXbyYY.c (see here).
声明在glibc/resolv/netdb.h里面,宏定义在inet/getthstbynm.c里面,真正的定义在nss/getXXbyYY.c里面
如下图所示,可以看到该函数是以 定义宏 “#define FUNCTION_NAME gethostbyname”再定义FUNCTION_NAME函数,通过宏替换的形式完成实质上的定义的。
声明
宏定义
定义(太长了,图片里只有前半部分)