我正在使用 Visual C++ express 2008 尝试编译类似于以下的代码:
没问题
{
...
AVRational test = {1, 1000};
...
}
Run Code Online (Sandbox Code Playgroud)
但出现问题如下:
{
...
AVRational test = (AVRational){1, 1000};
...
}
Run Code Online (Sandbox Code Playgroud)
给出了错误:
1>..\..\..\projects\test\xyz.cpp(1139) : error C2059: syntax error : '{'
1>..\..\..\projects\test\xyz.cpp(1139) : error C2143: syntax error : missing ';' before '{'
1>..\..\..\projects\test\xyz.cpp(1139) : error C2143: syntax error : missing ';' before '}'
Run Code Online (Sandbox Code Playgroud)
其中 AVRational(ffmpeg.org 库)定义为:
typedef struct AVRational{
int num; ///< numerator
int den; ///< denominator
} AVRational;
Run Code Online (Sandbox Code Playgroud)
FFmpeg 带有一些预定义的值,例如
#define AV_TIME_BASE_Q (AVRational){1, …Run Code Online (Sandbox Code Playgroud)