Reputation: 8384
gcc compiles fine on the following code
enum AVMediaType {
AVMEDIA_TYPE_UNKNOWN = -1,
AVMEDIA_TYPE_VIDEO,
AVMEDIA_TYPE_AUDIO,
AVMEDIA_TYPE_DATA,
AVMEDIA_TYPE_SUBTITLE,
AVMEDIA_TYPE_ATTACHMENT,
AVMEDIA_TYPE_NB
};
static int wanted_stream[AVMEDIA_TYPE_NB]={
[AVMEDIA_TYPE_AUDIO]=-1, // Line 234
[AVMEDIA_TYPE_VIDEO]=-1,
[AVMEDIA_TYPE_SUBTITLE]=-1,
};
but g++ throws the following error
playerthread.cpp:234: error: expected primary-expression before '[' token
What's the issue here?
Upvotes: 1
Views: 261
Reputation: 8195
These kind of designated initializers aren't supported by g++, but they are by gcc. I'm not certain it's allowed in the C++ standard at all. You can see the same if you bring the code down to a very simple:
int array[10] = { [1] = 5 };
It's fine in C, not C++.
Upvotes: 1