`socklen_t' has not been declared
羽飞 2012-09-13 08:52:04 我在SunOS上编译一个东西,出现下面的错误:
In file included from /data03/OBGRP/ob60/ob_rel/include/public/common/base/base_func.h:23,
from /data03/OBGRP/ob60/ob_rel/include/public/common/sdlbuffer/sdl_basic_objs.h:19,
from /data01/JFGRP/wangyl11/work/openbilling60/mediation/codec/sdl/codec_sdl_c.h:16,
from ../src/realtime.h:5,
from ../src/socket_for_tcpserver.cpp:10:
/usr/include/arpa/inet.h:69: error: `socklen_t' has not been declared
/usr/include/arpa/inet.h:72: error: `in_addr_t' does not name a type
/usr/include/arpa/inet.h:74: error: `in_addr_t' does not name a type
/usr/include/arpa/inet.h:75: error: variable `in_addr inet_makeaddr' has initializer but incomplete type
/usr/include/arpa/inet.h:75: error: `in_addr_t' was not declared in this scope
/usr/include/arpa/inet.h:75: error: `in_addr_t' was not declared in this scope
/usr/include/arpa/inet.h:76: error: `in_addr_t' does not name a type
/usr/include/arpa/inet.h:77: error: `in_addr_t' does not name a type
/usr/include/arpa/inet.h:75: error: storage size of `inet_makeaddr' isn't known
上面的说未定义的都可以在/usr/include/netinet/in.h中找到,其中socklen_t在两个文件中定义过:netinet/in.h和sys/socket.h;
在netinet/in.h中有如下的描述:
/*
* The socklen definitions are reproduced here from sys/socket.h so as to
* not introduce that namespace into existing users of netinet/in.h.
*/
在sys/socket.h中有如下的描述:
/*
* The socklen definitions are reproduced in netinet/in.h for the inet6_
* functions. Exposing all of sys/socket.h via netinet/in.h breaks existing
* applications and is not required by austin.
*/
在这个文件 /usr/include/arpa/inet.h 中:
#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
#include <sys/socket.h>
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
#include <netinet/in.h>
#if defined(_XPG4_2) && !defined(__EXTENSIONS__)
#include <sys/byteorder.h>
#endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */