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

缺乏、安全感 2022-09-23 11:00 114阅读 0赞

编译网络程序是出现错误:
error: ‘struct hostent’ has no member named ‘h_addr’
查看相应的头文件里面有h_addr 成员

  1. /* Description of data base entry for a single host. */
  2. struct hostent
  3. {
  4. char *h_name; /* Official name of host. */
  5. char **h_aliases; /* Alias list. */
  6. int h_addrtype; /* Host address type. */
  7. int h_length; /* Length of address. */
  8. char **h_addr_list; /* List of addresses from name server. */
  9. #if defined __USE_MISC || defined __USE_GNU
  10. # define h_addr h_addr_list[0] /* Address, for backward compatibility.*/
  11. #endif
  12. };

原因是编译是没有加相应的选项-D_GNU_SOURCE

发表评论

表情:
评论列表 (有 0 条评论,114人围观)

还没有评论,来说两句吧...

相关阅读