具有C语言功能的枚举

mus*_*vuz 1 c

当我检查ffmpeg的源代码时,我看到这一行:

enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method
(const AVFormatContext* ctx);
Run Code Online (Sandbox Code Playgroud)

enum这里有什么功能?

Jey*_*ram 8

av_fmt_ctx_get_duration_estimation_method是一个返回枚举类型对象的函数AVDurationEstimationMethod.


Yu *_*Hao 5

enum AVDurationEstimationMethodtogether是函数av_fmt_ctx_get_duration_estimation_method返回的类型

关键字enumstruct和类似union,是表示类型的必要条件.要省略它,请使用typedef:

typedef enum AVDurationEstimationMethod sometype;
Run Code Online (Sandbox Code Playgroud)

然后你就可以使用它:

sometype av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx);
Run Code Online (Sandbox Code Playgroud)