B
BartC
I get the error 'too many initialisers' with this code:
int x;
int main (void) {
int table[]=
{0,
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x)
};
}
Is there something I'm doing wrong, or another compiler bug to be reported?
(I've already found another - now confirmed - bug with another compiler
earlier today; compiler bugs are supposed to be extremely rare.)
The problem goes away if I have just one less item (the original code has
272), or I replace &x with just x.
Or if I just use a pointer array, which I think I'll use as a workaround.
(This compiler is 64-bits so there would likely be issues with pointer
truncation anyway, although the compiler didn't report this. I haven't used
a pointer array already because the x's are really function pointers in the
original code, and I would have to dig out CDECL to get it right.)
(BTW I'm trying recompiling the same project with 4 or 5 different
compilers. They all report different things as errors! How does anyone
manage to write any sizeable C project and keep multiple compilers happy at
the same time? They all have slightly different link requirements too!)
int x;
int main (void) {
int table[]=
{0,
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x),
((int)&x)
};
}
Is there something I'm doing wrong, or another compiler bug to be reported?
(I've already found another - now confirmed - bug with another compiler
earlier today; compiler bugs are supposed to be extremely rare.)
The problem goes away if I have just one less item (the original code has
272), or I replace &x with just x.
Or if I just use a pointer array, which I think I'll use as a workaround.
(This compiler is 64-bits so there would likely be issues with pointer
truncation anyway, although the compiler didn't report this. I haven't used
a pointer array already because the x's are really function pointers in the
original code, and I would have to dig out CDECL to get it right.)
(BTW I'm trying recompiling the same project with 4 or 5 different
compilers. They all report different things as errors! How does anyone
manage to write any sizeable C project and keep multiple compilers happy at
the same time? They all have slightly different link requirements too!)