Following on from this discussion: http://www.8052.com/forum/read.phtml?id=84814 Keil C51 v7.50 rejects the following:
char key_tbl[][] = { { 4, 3, 2, 1 }, // row 0 { 8, 7, 6, 5 }, // row 1 { 12, 11, 10, 9 }, // row 2 { 16, 15, 14, 13 }, // row 3 };
MAIN.C(27): error C163: 'key_tbl': unknown array size
In a multi-dimensional array, only the leftmost [] can be left empty. All other bounds must be specified. Note that initializers are not all or nothing. You can legally initialize just a bit of an array, while all the rest default to zero: char arr[10] = { 'a', 'b', 'c' }; This fact prevents the compiler from deducing the size of inner elements soley from the initializer. I've moved away from the practice of undeclared array sizes. Generally your specs or design docs tell you how many entries you must support. And the size of the array is often needed in loop bounds and other places. sizeof() can sometimes, but not always, determine the size of the array. So, I find it better to #define an array size constant (or often, use an extra value in a enum for that purpose). This constant is used in the array definition as well as other places to ensure consistency and allow the compiler to provide error messages for lack of initializers or too many initializers.