我正在处理的项目包括以下内容
#include <memory.h>
#include <signal.h>
#include <errno.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#ifdef __linux__
# include <linux/tcp.h>
#else
# include <sys/time.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <netinet/tcp_var.h>
#endif我正在64位mac上编译。当到达tcp_var.h include时,编译器会抛出以下错误:
/usr/include/netinet/in_pcb.h:192:17: error: field has incomplete type 'struct xsocket'
struct xsocket xi_socket;
^
/usr/include/netinet/in_pcb.h:192:9: note: forward declaration of 'xsocket'
struct xsocket xi_socket;
^
/usr/include/netinet/in_pcb.h:235:20: error: field has incomplete type 'struct xsocket64'
struct xsocket64 xi_socket;
^
/usr/include/netinet/in_pcb.h:235:10: note: forward declaration of 'xsocket64'
struct xsocket64 xi_socket;
^
/usr/include/netinet/in_pcb.h:245:2: error: unknown type name 'so_gen_t'
so_gen_t xig_sogen; /* current socket generation count */
^
In file included from .../tcp_client_listener.cc:52:
/usr/include/netinet/tcp_var.h:373:25: error: field has incomplete type 'struct xsocket'
struct xsocket xt_socket;
^
/usr/include/netinet/in_pcb.h:192:9: note: forward declaration of 'xsocket'
struct xsocket xi_socket;
^
/Users/Justin/Projects/smartdevicelink/SDL_Core/src/components/transport_manager/src/tcp/tcp_client_listener.cc:141:44: error: use of undeclared identifier
'TCP_USER_TIMEOUT'
setsockopt(connection_fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &user_timeout, sizeof(user_timeout));有没有不同的库可以包含在#ifdef MAC_OSX指令中,或者有办法修复这个转发声明并保持与其他mac的兼容性?
发布于 2018-12-12 01:35:37
这一切都是关于你导入标题的顺序!
此命令可用
#import <sys/socketvar.h>
#import <netinet/in.h>
#import <netinet/tcp_var.h>
#import <netinet/tcp.h>
#import <sys/socket.h>发布于 2014-03-20 02:44:11
使用
#include <sys/socket.h>在else部分
https://stackoverflow.com/questions/22514928
复制相似问题