‘sockaddr_in6_t’即使包含头文件也会出现未声明的错误
我有以下简单的代码,它是一个大项目中 ipv6 处理模块的一部分。
#include <ctype.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/stat.h>
int main(){
sockaddr_in6_t* pSadrIn6 = (sockaddr_in6_t*) malloc(sizeof sockaddr_in6_t);
return 0;
}
它给了我以下而不是错误:
error: ‘sockaddr_in6_t’ undeclared (first use in this function)
是否有任何特殊的库安装或链接我需要访问该库?
I have following simple piece of code, which is a part of ipv6 handling module in a big project.
#include <ctype.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/stat.h>
int main(){
sockaddr_in6_t* pSadrIn6 = (sockaddr_in6_t*) malloc(sizeof sockaddr_in6_t);
return 0;
}
It gives me following not error:
error: ‘sockaddr_in6_t’ undeclared (first use in this function)
Is there any special library installation or linking that I need to access the library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您是从 Linux IPv6 HOWTO< 复制了此代码/a> 但没有复制额外的 typedef:
就个人而言,我会按原样使用类型(而不是额外的
typedefs
以避免输入struct
),但无论如何It looks like you copied this code from the Linux IPv6 HOWTO but didn't copy the additional typedefs:
Personally I would just use the types as they are (instead of extra
typedefs
to avoid typingstruct
), but whatever