Initialisation of structs containing arrays of structs...?
Hi. I am having trouble comprehending why this shouldn't work? Is it a bug
with Turbo C++ 3.0?
//************BEGIN CODE***********
typedef struct {
byte fore, back;
} fore_back;
typedef struct {
fore_back status[4];
} pbcolours;
typedef struct {
struct {
fore_back indicator;
fore_back text;
} status[4];
} cbrbcolours;
pbcolours defaultpbcolours[2] = {{{15, 8}, {15, 4}, {8, 7}, {0, 11}},
{{15, 8}, {15, 1}, {8, 7}, {0, 11}}};
cbrbcolours defaultcbrbcolours[2] = {{{{3, 1}, {3, 1}}, {{14, 1}, {15, 1}},
{{8, 1}, {8, 1}}, {{12, 1}, {15, 1}}},
{{{3, 4}, {3, 4}}, {{14, 4}, {15, 4}},
{{8, 4}, {8, 4}}, {{12, 4}, {15, 4}}}};
//***************END CODE**************
This code consistently gives me "too many initialiser" messages... it seems
to want to accept only the data for status[0], as though this were a single
struct, rather than part of an array of them. There is no problem if I write
out the swath of code needed to assign each element in the main function,
i.e.
void main(void) {
defaultpbcolours[0].status[0].fore=15;
defaultpbcolours[0].status[0].back=8;
.
.
.
defaultcbrbcolours[1].status[3].text.back=4;
Quote:
}
This works fine, but is tedious... it is just when I try to initialise that
it doesn't work.
Also, if I replace the status arrays with four separate fore_back structs,
say status1, status2, status3 and status4, this same declaration works
perfectly... however, making such a replacement makes them cumbersome for my
purposes! I have only tried compiling this with Turbo C++ 3.0 (as that's the
only compiler I have) .. and I am using this in a C++ (as opposed to plain
C) program.
Thanks for any help.
"Desparate" Damon :-)