您的位置:首页 > 理论基础 > 计算机网络

error: ‘struct hostent’ has no member named ‘h_addr’

2016-07-18 15:29 1271 查看
编译网络程序是出现错误:

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  网络