This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

No arrays of unsigned chars?



Admittedly, I'm not a real programmer.  Using CCS v4, I'm trying to program a microcontroller and want to use an array of unsigned char.  When I try to compile, CCS tells me "an array may not have elements of this type".  Here is the code that chokes:

unsigned char dotFont[][] = {
 {0x80,0x80,0x80,0x00,0x00,0x00,0x00},
 {0x80,0xf9,0xf9,0x00,0x00,0x00,0x00},
 {0x80,0xC0,0xf0,0x80,0xC0,0xf0,0x00},
 {0x80,0xA4,0xff,0xa4,0xff,0xa4,0x00},
 {0x80,0x94,0xac,0xff,0xcc,0xc4,0x00}
};


Is that really not allowed?  Please offer me some advice why this array is not allowed.

  • OK, by specifying the dimensions now it works.  I wouldn't have bothered anyone with this post if it said "you must specify the dimensions of the array" or even "illegal dimension specs".  Oh well.

  • In 'C', you cannot leave the size unspecified for all dimensions of a multi-dimension array - IIRC, only one can be left unspecified.

    The curly braces must match any dimensions specified - but they are not used to deduce an omitted dimension.

    'C' doesn't really have any special notion of multi-dimension arrays: they're all just arrays of "some type" - where that type might happen to be another array.
    Hence, when it said "elements of this type" it was referring to "elements of type array-with-unspecified-length" - not to the chars!