In a bit of code I'm looking at, a 3D array has been initialized like so:
static const char codeset[6][256][10] = {
[0] = { [0x20] = " ",
[0x21] = "!",
[0x22] = """,
[0x23] = "#",
}};
(It does go on to initialize the rest of the cells, I've cut it short to show something readable.)
This does not compile. Is it supposed to? What's going on here?
3 Answers 3
You are using C99 initializers, but your compiler does not support C99 or C99 is not enabled.
Comments
You are trying to use C99 initializers, but most likely your compiler isn't C99-compliant, otherwise it would work.
2 Comments
As a guess, it trying to create the "alphabet" for xml string ASCII data. The " (double quote) character in xml is represented as ". So the [0][0 - 255] group is xml.
It looks like an equivalence table. It translates from xml to ASCII or whatever.
-std=c99to your command line just to be on the safe side, as it's a C99 extension.