error: ‘struct hostent’ has no member named ‘h_addr’
编译网络程序是出现错误:
error: ‘struct hostent’ has no member named ‘h_addr’
查看相应的头文件里面有h_addr 成员
/* Description of data base entry for a single host. */
struct hostent
{
char *h_name; /* Official name of host. */
char **h_aliases; /* Alias list. */
int h_addrtype; /* Host address type. */
int h_length; /* Length of address. */
char **h_addr_list; /* List of addresses from name server. */
#if defined __USE_MISC || defined __USE_GNU
# define h_addr h_addr_list[0] /* Address, for backward compatibility.*/
#endif
};
原因是编译是没有加相应的选项-D_GNU_SOURCE
还没有评论,来说两句吧...