Reputation: 3490
Following is code snippet from the open source project X264, I got build error when try to port it to support VS compiler cl.exe
. The cl.exe
treat the [X264_PULLDOWN_22]
as the begin of lambda.
So can anybody explain what this line means in C language.
typedef struct
{
int mod;
uint8_t pattern[24];
float fps_factor;
} cli_pulldown_t;
enum pulldown_type_e
{
X264_PULLDOWN_22 = 1,
X264_PULLDOWN_32,
X264_PULLDOWN_64,
X264_PULLDOWN_DOUBLE,
X264_PULLDOWN_TRIPLE,
X264_PULLDOWN_EURO
};
#define TB PIC_STRUCT_TOP_BOTTOM
#define BT PIC_STRUCT_BOTTOM_TOP
#define TBT PIC_STRUCT_TOP_BOTTOM_TOP
#define BTB PIC_STRUCT_BOTTOM_TOP_BOTTOM
static const cli_pulldown_t pulldown_values[] =
{
/*WHAT DOES THIS LINE MEAN???, how can you assign to [X264_PULLDOWN_22]*/
[X264_PULLDOWN_22] = {1, {TB}, 1.0},
[X264_PULLDOWN_32] = {4, {TBT, BT, BTB, TB}, 1.25},
[X264_PULLDOWN_64] = {2, {PIC_STRUCT_DOUBLE, PIC_STRUCT_TRIPLE}, 1.0},
[X264_PULLDOWN_DOUBLE] = {1, {PIC_STRUCT_DOUBLE}, 2.0},
[X264_PULLDOWN_TRIPLE] = {1, {PIC_STRUCT_TRIPLE}, 3.0},
[X264_PULLDOWN_EURO] = {24, {TBT, BT, BT, BT, BT, BT, BT, BT, BT, BT, BT, BT,
BTB, TB, TB, TB, TB, TB, TB, TB, TB, TB, TB, TB}, 25.0/24.0}
};
Upvotes: 1
Views: 95
Reputation: 33273
It's called a designated initializer and is a shorthand way to initialize variables.
How to fix your compilation problem:
Set the compiler complience to C99 or later.
or
Change the initializer to initialize all elements of the array:
static const cli_pulldown_t pulldown_values[] =
{
{0, NULL, 0.0}, // Added initializer for element 0
{1, {TB}, 1.0},
{4, {TBT, BT, BTB, TB}, 1.25},
{2, {PIC_STRUCT_DOUBLE, PIC_STRUCT_TRIPLE}, 1.0},
{1, {PIC_STRUCT_DOUBLE}, 2.0},
{1, {PIC_STRUCT_TRIPLE}, 3.0},
{24, {TBT, BT, BT, BT, BT, BT, BT, BT, BT, BT, BT, BT,
BTB, TB, TB, TB, TB, TB, TB, TB, TB, TB, TB, TB}, 25.0/24.0}
};
Upvotes: 1
Reputation: 2149
Others have said what it is. Compiling with C compiler, not C++, should fix it, since it's not a standard part of C++.
Upvotes: 1