星空网 > 软件开发 > 操作系统

splice()函数,SPLICE_F_MOVE SPLICE_F_NONBLOCK SPLICE_F_MORE undeclared

1.编译含有splice()函数的程序时出现,'SPLICE_F_MOVE'  undeclared,'SPLICE_F_NONBLOCK' ‘SPLICE_F_MORE' 也是一样undeclared!

2.使用man splice查看,发现要定义宏_GNU_SOURCE

1 #define _GNU_SOURCE     /* See feature_test_macros(7) */2 #include <fcntl.h>3 4 ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags);

我们跟着后面宏的注释See feature_test_macros(7)

1 $:man feature_test_macros

man手册上面的描述是:特性测试宏允许程序编译时控制系统头文件的宏定义!

1 NAME2    feature_test_macros - feature test macros3 4 SYNOPSIS5    #include <features.h>6 7 DESCRIPTION8    Feature test macros allow the programmer to control the definitions that are exposed by system header files when a program is compiled.

 

3.我们找找看,splice()函数的这个几个flags参数宏定义在哪里。splice()函数定义在<fcntl.h>头文件里面,查看头文件

1 $:vim /usr/include/fcntl.h

然而里面并没有这几个宏,但里面有包含了<features.h>,<bits/fcntl.h>文件,我们跟进去这2个文件。我的系统是64位的kail。

bits文件夹在/usr/include/x86_64-linux-gnu/bits/

1 $:vim /usr/include/features.h2 $:vim /usr/include/x86_64-linux-gnu/bits/fcntl.h

这2个里面都也没有,<bits/fcntl.h>文件里面又包含了<bits/fcntl-linux.h>。我们继续跟进。

1 $:vim /usr/include/x86_64-linux-gnu/bits/fcntl-linux.h

这次我们找到了:

1 /* Flags for SPLICE and VMSPLICE. */2 # define SPLICE_F_MOVE   1  /* Move pages instead of copying. */3 # define SPLICE_F_NONBLOCK 2  /* Don't block on the pipe splicing4             (but we may still block on the fd5             we splice from/to). */6 # define SPLICE_F_MORE   4  /* Expect more data. */7 # define SPLICE_F_GIFT   8  /* Pages passed in are a gift. */

4.现在我们根据这几个宏定义的上下文来查看跟_GNU_SOURCE宏的联系。

这4个宏包含在#ifdef __USE_GNU里面,我回头在看看features.h

1 $:vim /usr/include/features.h

直接搜索__USE_GNU,发现里面有这个定义,跟_GNU_SOURCE关联。

#ifdef _GNU_SOURCE# define __USE_GNU 1#endif

5.如果不注重里面的包含细节,直接用grep搜索,简单粗暴!!!

$:grep -rn 'SPLICE_F' /usr/include/

 




原标题:splice()函数,SPLICE_F_MOVE SPLICE_F_NONBLOCK SPLICE_F_MORE undeclared

关键词:函数

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

深圳快递发越南:https://www.goluckyvip.com/tag/105881.html
上海 越南 快递:https://www.goluckyvip.com/tag/105882.html
发往越南物流公司:https://www.goluckyvip.com/tag/105884.html
中国邮寄快递到越南:https://www.goluckyvip.com/tag/105885.html
寄到越南的快递怎么查询:https://www.goluckyvip.com/tag/105886.html
寄到越南费用:https://www.goluckyvip.com/tag/105887.html
37号文今后是否会更新?一文详解关键信息 :https://www.kjdsnews.com/a/1836441.html
探讨内地人开设香港账户的可行性 :https://www.kjdsnews.com/a/1836442.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流