首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >包含<netinet/tcp_var.h>错误:字段的类型'struct xsocket‘不完整

包含<netinet/tcp_var.h>错误:字段的类型'struct xsocket‘不完整
EN

Stack Overflow用户
提问于 2014-03-20 02:26:09
回答 2查看 649关注 0票数 1

我正在处理的项目包括以下内容

代码语言:javascript
复制
#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时,编译器会抛出以下错误:

代码语言:javascript
复制
/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的兼容性?

EN

回答 2

Stack Overflow用户

发布于 2018-12-12 01:35:37

这一切都是关于你导入标题的顺序!

此命令可用

代码语言:javascript
复制
#import <sys/socketvar.h>
#import <netinet/in.h>
#import <netinet/tcp_var.h>
#import <netinet/tcp.h>
#import <sys/socket.h>
票数 1
EN

Stack Overflow用户

发布于 2014-03-20 02:44:11

使用

代码语言:javascript
复制
 #include <sys/socket.h>

在else部分

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22514928

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档