V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
nougat2014
V2EX  ›  互联网

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

  •  
  •   nougat2014 · 2015-10-28 16:09:49 +08:00 · 4787 次点击
    这是一个创建于 3349 天前的主题,其中的信息可能已经有所发展或是发生改变。

    刚刚开始看 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

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   935 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 20:16 · PVG 04:16 · LAX 12:16 · JFK 15:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.