#ifndef av_const
#if defined(__GNUC__) && (__GNUC__ > 2 &brvbar &brvbar __GNUC__ == 2 && __GNUC_MINOR__ > 5)
#    define av_const __attribute__((const))
#else
#    define av_const
#endif
#endif

下面这2行到底定义了个什么东西?
#    define av_const __attribute__((const))
#    define av_const

还有:
typedef struct AVRational{
    int num; /// < numerator
    int den; /// < denominator
} AVRational;

AVRational av_mul_q(AVRational b, AVRational c) av_const;
AVRational av_div_q(AVRational b, AVRational c) av_const;
上面这2个函数定义的后面的av_const(就是上面定义的)表示什么?这个函数是返回了这个结构还是这个结构的指针?

谢谢!

__attribute__ const
  该属性只能用于带有数值类型参数的函数上。当重复调用带有数值参数的函数时,由于返回值是相同的,所以此时编译器能够进行优化处理,除第一次需要运算外,其他只需要返回第一次的结果就能够了,进而能够提高效率。该属性主要适用于没有静态状态(static state)和副作用的一些函数,并且返回值仅仅依赖输入的参数。

该回复于2008-08-27 09:06:08被版主删除

下面的typedef是定义了1个结构体