包含netinet/in.h和sys/socket.h编译会出错?

weixin_38087646 2003-05-26 05:03:57

程序简单:
//----------test.c---------
#include <sys/socket.h>;
main()
{
    return 0;
}
//-------------------------
gcc -o test test.c编译出错如下:
/usr/include/sys/socket.h:52: syntax error before `sa_family_t'
/usr/include/sys/socket.h:52: warning: data definition has no type or storag
e class
/usr/include/sys/socket.h:163: syntax error before `u_char'
/usr/include/sys/socket.h:174: syntax error before `u_short'
/usr/include/sys/socket.h:188: syntax error before `u_char'
<下面的错误消息省略>;
  
  

  
又有如果include了<netinet/in.h>;
就会出现下面的错误:
/usr/include/netinet/in.h:233: syntax error before `in_addr_t'
/usr/include/netinet/in.h:285: syntax error before `u_char'
In file included from /usr/include/netinet/in.h:475,
                 from test.c:1:
/usr/include/netinet6/in6.h:122: syntax error before `u_int8_t'
/usr/include/netinet6/in6.h:144: syntax error before `u_int8_t'
/usr/include/netinet6/in6.h:149: syntax error before `u_int32_t'
/usr/include/netinet6/in6.h:606: syntax error before `struct'
<下面还有的错误省略>;
  
请问这是为什么呢?我用FreeBSD5.0Release. 注:在LINUX下是没有出错的.
...全文
39 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧