我正在阅读avio.h(ffmpeg的一部分),并且有这样的定义(?):
int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);.
我不明白.有人能解释一下这是做什么的吗?谢谢.
int*_*jay 24
av_printf_format是一个宏,可以选择将GCC属性添加到函数声明中.它在attributes.h中定义:
#ifdef __GNUC__
# define av_builtin_constant_p __builtin_constant_p
# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
#else
# define av_builtin_constant_p(x) 0
# define av_printf_format(fmtpos, attrpos)
#endif
Run Code Online (Sandbox Code Playgroud)
所以这实际上是一个函数声明,如果在GCC上编译,它可能有一个特定的属性.
该format属性告诉GCC该函数采用其参数printf,这有助于诊断一些错误.