UNIX 网络编程 编译环境出错 求解答

2015-10-28 16:09:49 +08:00
 nougat2014

刚刚开始看 UNIX 网络编程的书,下载了随书的程序源码,按照 README 文件进行环境配置的时候,在第二步 make 的时候出错了,出错原因如下:
(开发环境是 cs50 给的虚拟机)
jharvard@appliance (~/Downloads/unpv13e/lib): make
clang -I../lib -ggdb3 -O0 -std=c99 -Wall -Werror -D_REENTRANT -Wall -c -o connect_nonb.o connect_nonb.c
In file included from connect_nonb.c:1:
In file included from ../lib/unp.h:13:
/usr/include/i386-linux-gnu/sys/types.h:109:19: error: cannot combine with
previous 'type-name' declaration specifier
typedef __ssize_t ssize_t;
^
../lib/../config.h:311:17: note: expanded from macro 'ssize_t'

define ssize_t int

^

In file included from connectnonb.c:1:
In file included from ../lib/unp.h:13:
In file included from /usr/include/i386-linux-gnu/sys/types.h:146:
/usr/bin/../lib/clang/3.4/include/stddef.h:42:23: error: cannot combine with
previous 'int' declaration specifier
typedef __SIZE_TYPE
_ size_t;
^
../lib/../config.h:302:25: note: expanded from macro 'size_t'

define size_t unsigned int

^

In file included from connectnonb.c:1:
In file included from ../lib/unp.h:13:
/usr/include/i386-linux-gnu/sys/types.h:196:1: error: cannot combine with
previous 'int' declaration specifier
__intN_t (32, __SI
);
^
/usr/include/i386-linux-gnu/sys/types.h:188:15: note: expanded from macro
'
intN_t'
typedef int int##N##_t __attribute
_ ((mode (MODE)))
^
<scratch space>:14:1: note: expanded from here
int32_t
^
../lib/../config.h:296:17: note: expanded from macro 'int32_t'

define int32_t int

^

In file included from connect_nonb.c:1:
In file included from ../lib/unp.h:14:
In file included from /usr/include/i386-linux-gnu/sys/socket.h:38:
/usr/include/i386-linux-gnu/bits/socket.h:33:21: error: cannot combine with
previous 'type-name' declaration specifier
typedef __socklen_t socklen_t;
^
../lib/../config.h:305:28: note: expanded from macro 'socklen_t'

define socklen_t unsigned int

^

In file included from connect_nonb.c:1:
In file included from ../lib/unp.h:14:
In file included from /usr/include/i386-linux-gnu/sys/socket.h:38:
/usr/include/i386-linux-gnu/bits/socket.h:33:21: error: 'type-name' cannot be
signed or unsigned
../lib/../config.h:305:19: note: expanded from macro 'socklen_t'

define socklen_t unsigned int

^

In file included from connect_nonb.c:1:
In file included from ../lib/unp.h:25:
In file included from /usr/include/netinet/in.h:22:
In file included from /usr/bin/../lib/clang/3.4/include/stdint.h:62:
In file included from /usr/bin/../lib/gcc/i686-linux-gnu/4.8/include/stdint.h:9:
/usr/include/stdint.h:48:24: error: cannot combine with previous 'char'
declaration specifier
typedef unsigned char uint8_t;
^
../lib/../config.h:326:26: note: expanded from macro 'uint8_t'

define uint8_t unsigned char

^

In file included from connect_nonb.c:1:
In file included from ../lib/unp.h:25:
In file included from /usr/include/netinet/in.h:22:
In file included from /usr/bin/../lib/clang/3.4/include/stdint.h:62:
In file included from /usr/bin/../lib/gcc/i686-linux-gnu/4.8/include/stdint.h:9:
/usr/include/stdint.h:51:23: error: cannot combine with previous 'int'
declaration specifier
typedef unsigned int uint32_t;
^
../lib/../config.h:323:27: note: expanded from macro 'uint32_t'

define uint32_t unsigned int

^

In file included from connect_nonb.c:1:
../lib/unp.h:227:8: error: redefinition of 'sockaddr_storage'
struct sockaddr_storage {
^
/usr/include/i386-linux-gnu/bits/socket.h:162:8: note: previous definition is
here
struct sockaddr_storage
^
In file included from connect_nonb.c:1:
../lib/unp.h:263:8: error: redefinition of 'timespec'
struct timespec {
^
/usr/include/time.h:120:8: note: previous definition is here
struct timespec
^
In file included from connect_nonb.c:1:
../lib/unp.h:286:1: error: unknown type name 'u_char'
u_char inet_srcrt_init(int);
^
../lib/unp.h:287:24: error: unknown type name 'u_char'
void inet_srcrt_print(u_char *, int);
^
../lib/unp.h:458:21: error: type specifier missing, defaults to 'int'
[-Werror,-Wimplicit-int]
void Sysctl(int *, u_int, void *, size_t *, void *, size_t);
^~~~~
12 errors generated.
make: *
* [connect_nonb.o] Error 1

4787 次点击
所在节点    互联网
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/231752

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX