javametro 发表于 2014-03-20 20:17

关于linux下splice的使用

本帖最后由 javametro 于 2014-03-20 20:18 编辑

自己在学习socket编程,写的demo,然后编译的时候出现如下提示:# gcc -o reply reply.c
reply.c: In function ‘main’:
reply.c:46: error: ‘SPLICE_F_MORE’ undeclared (first use in this function)
reply.c:46: error: (Each undeclared identifier is reported only once
reply.c:46: error: for each function it appears in.)
reply.c:46: error: ‘SPLICE_F_MOVE’ undeclared (first use in this function)使用的是splice的系统调用,按理说这个宏定义应该是在头文件中定义了的啊,怎么会这样呢?
还请大家指教 。


timespace 发表于 2014-03-20 21:05

gcc不会自动帮你找定义,要自己包含相应的头文件

javametro 发表于 2014-03-26 19:26

回复 2# timespace


    头文件是包含进来了的。

timespace 发表于 2014-03-26 20:47

NAME
       splice - splice data to/from a pipe

SYNOPSIS
       #define _GNU_SOURCE         /* See feature_test_macros(7) */
       #include <fcntl.h>

       ssize_t splice(int fd_in, loff_t *off_in, int fd_out,
                      loff_t *off_out, size_t len, unsigned int flags);
回复 2# timespace

有定义宏_GNU_SOURCE吗?


   
页: [1]
查看完整版本: 关于linux下splice的使用