ChinaFFmpeg

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 16262|回复: 10

[源码] 【求助】函数定义()后面;前面还能接代码块吗?

[复制链接]
发表于 2013-10-17 15:51:18 | 显示全部楼层 |阅读模式

疑问代码如上图(文件位置Location:ffmpeg/libavutil/mem.h):

C语言有这种语法吗?求解释

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

发表于 2013-10-17 15:54:20 | 显示全部楼层

  1. 63 #if AV_GCC_VERSION_AT_LEAST(3,1)
  2. 64     #define av_malloc_attrib __attribute__((__malloc__))
  3. 65 #else
  4. 66     #define av_malloc_attrib
  5. 67 #endif
  6. 68
  7. 69 #if AV_GCC_VERSION_AT_LEAST(4,3)
  8. 70     #define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__)))
  9. 71 #else
  10. 72     #define av_alloc_size(...)
  11. 73 #endif
  12. 74
  13. 75 /**
  14. 76  * Allocate a block of size bytes with alignment suitable for all
  15. 77  * memory accesses (including vectors if available on the CPU).
  16. 78  * @param size Size in bytes for the memory block to be allocated.
  17. 79  * @return Pointer to the allocated block, NULL if the block cannot
  18. 80  * be allocated.
  19. 81  * @see av_mallocz()
  20. 82  */
  21. 83 void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
复制代码
其实就是根据编译器重新定义了一下
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-10-17 16:37:22 | 显示全部楼层
T-Bagwell 发表于 2013-10-17 15:54
其实就是根据编译器重新定义了一下

嗯,但是我的疑惑是在C语言的语法里面函数定义()后面;前面还能接代码块吗?求解
回复 支持 反对

使用道具 举报

发表于 2013-10-17 16:38:53 | 显示全部楼层
pqiankui 发表于 2013-10-17 16:37
嗯,但是我的疑惑是在C语言的语法里面函数定义()后面;前面还能接代码块吗?求解 ...

在Linux下这么写过……
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-10-17 16:40:38 | 显示全部楼层
T-Bagwell 发表于 2013-10-17 16:38
在Linux下这么写过……

啥意思啊
回复 支持 反对

使用道具 举报

发表于 2013-10-17 17:01:25 | 显示全部楼层
这个在zlib里面也有,是.c的语法
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-10-17 17:05:45 | 显示全部楼层
T-Bagwell 发表于 2013-10-17 17:01
这个在zlib里面也有,是.c的语法

大师兄能帮忙找找文献资料我学习补习下知识吗?
回复 支持 反对

使用道具 举报

发表于 2013-10-17 17:27:19 | 显示全部楼层
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-10-17 17:58:11 | 显示全部楼层
孙悟空 发表于 2013-10-17 17:27
http://en.wikipedia.org/wiki/C_(programming_language)

好吧,这答案太高深了,en.Wiki
回复 支持 反对

使用道具 举报

发表于 2013-10-17 22:44:53 | 显示全部楼层
av_malloc_attrib是编译器的优化参数, 保证了指针的唯一性
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|Archiver|ChinaFFmpeg

GMT+8, 2024-4-26 08:31 , Processed in 0.056256 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表