博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ffmpeg 中的GNU语法
阅读量:7026 次
发布时间:2019-06-28

本文共 1596 字,大约阅读时间需要 5 分钟。

阅读ffmpeg源码是 发现一些函数前面加了 attribute_deprecated 属性;如:attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags);

在libavutil/attributes.h  中有如下定义:

#ifndef attribute_deprecated
#if AV_GCC_VERSION_AT_LEAST(3,1)
#    define attribute_deprecated __attribute__((deprecated))
#else
#    define attribute_deprecated
#endif
#endif

__attribute__ 语法为GNU C 的特性,__attribute__可以设置函数属性(Function Attribute)、变量属性(Variable Attribute)和类型属性(Type Attribute)。

__attribute__语法格式为:__attribute__ ((attribute))
需要注意的是: 使用__attribute__的时候,只能函数的声明处使用__attribute__,并且在“;“前。

在开发一些库的时候,API的接口可能会过时,为了提醒开发者这个函数已经过时。只要函数被使用,在编译是都会产生警告,警告信息中包含过时接口的名称及代码中的引用位置。

下面是GNU 网站()上对这个属性的解释:
deprecated
The deprecated attribute results in a warning if the function is used anywhere in the source file. This is useful when identifying functions that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated function, to enable users to easily find further information about why the function is deprecated, or what they should do instead. Note that the warnings only occurs for uses:
          int old_fn () __attribute__ ((deprecated));
          int old_fn ();
          int (*fn_ptr)() = old_fn;
     
results in a warning on line 3 but not line 2.
下面是一个列子:
# cat gnu.c

#include <stdlib.h>
#include <stdio.h>
__attribute__((deprecated)) 
void attribute();
void attribute()
ExpandedBlockStart.gif {
 printf("GNU attribute \n");
}
int main()
ExpandedBlockStart.gif {
 attribute();
 
return 0;
}

# gcc gnu.c -o gnu 

gnu.c: In function ‘main’:
gnu.c:12: warning: ‘attribute’ is deprecated (declared at gnu.c:5)     //编译警告
# ./gnu 
GNU attribute

转载地址:http://vkmxl.baihongyu.com/

你可能感兴趣的文章
画之国 Le tableau (2011)
查看>>
jquery淡入淡出无延迟代码
查看>>
js 规范
查看>>
OpenCV入门学习(三)HistogramEquivalent
查看>>
Intellij IDEA 10.5 语言设置
查看>>
Activity 中的Toast在Activity销毁后报错,解决方法,把context改成应用的
查看>>
解决服务器SID引起虚拟机不能加入AD域用户,无法远程登录的问题
查看>>
Don't let self-built concept imprison yourself
查看>>
08.LoT.UI 前后台通用框架分解系列之——多样的Tag选择器
查看>>
python property 学习
查看>>
perl file find
查看>>
jQuery方法position()与offset()区别
查看>>
Flume特点
查看>>
队列 句子分析 精辟的诠释 有图片
查看>>
在switch的default代码块中增加AssertionError错误
查看>>
JS:1.3,函数(function)
查看>>
Ubuntu下升级Git以及获取ssh keys的代码
查看>>
在C#代码中应用Log4Net(一)简单使用Log4Net
查看>>
webservice 测试窗体只能用于来自本地计算机的请求
查看>>
让WordPress主题支持语言本地化(使用poedit软件实现中文翻译功能)
查看>>