首页 > UNP源码编译出错,不明所以

UNP源码编译出错,不明所以

系统:Ubuntu 12.10 GCC: gcc 4.7.2 Glibc:2.15

编译/unpv13e/lib/wrapsock.c时发生如下错误

gcc -Wall -c wrapsock.c -o wrapsock.o
wrapsock.c: 在函数‘Inet6rthspace’中: wrapsock.c:82:2: 警告: 隐式声明函数‘inet6rthspace’ [-Wimplicit-function-declaration]
wrapsock.c: 在函数‘Inet6rthinit’中: wrapsock.c:94:2: 警告: 隐式声明函数‘inet6rthinit’ [-Wimplicit-function-declaration]
wrapsock.c:94:6: 警告: 赋值时将整数赋给指针,未作类型转换 [默认启用]
wrapsock.c: 在函数‘Inet6rthadd’中: wrapsock.c:104:2: 警告: 隐式声明函数‘inet6rthadd’ [-Wimplicit-function-declaration]
wrapsock.c: 在函数‘Inet6rthreverse’中: wrapsock.c:111:2: 警告: 隐式声明函数‘inet6rthreverse’ [-Wimplicit-function-declaration]
wrapsock.c: 在函数‘Inet6rthsegments’中: wrapsock.c:120:2: 警告: 隐式声明函数‘inet6rthsegments’ [-Wimplicit-function-declaration]
wrapsock.c: 在函数‘Inet6rthgetaddr’中: wrapsock.c:132:2: 警告: 隐式声明函数‘inet6rthgetaddr’ [-Wimplicit-function-declaration]
wrapsock.c:132:6: 警告: 赋值时将整数赋给指针,未作类型转换 [默认启用]

可是在 unp.h中明确包含了了<netinet/in.h>
在netinet/in.h中找到如下
576 extern socklent inet6rthspace (int type, int __segments) __THROW;
577 extern void *inet6_rth_init (void *
bp, socklen
t bplen, int __type,
579 extern int inet6
rth_add (void *
bp, const struct in6_addr *addr) THROW;
580 extern int inet6rthreverse (
const void *in, void *out) THROW;
581 extern int inet6rthsegments (
const void *bp) __THROW;
582 extern struct in6addr *inet6rth_getaddr (
const void *__bp, int __index)


netinet/in.h里,在定义ipv6相关function的prototype前,有个#ifdef __USE_GNU。而这个是由#ifdef _GNU_SOURCE控制的。所以你需要在unp.h里加入#define _GNU_SOURCE,就可以了。

【热门文章】
【热门文章】