I have the following code:
struct something {
char *(*choices)[2];
};
char* arr[2] = {"foo", "bar"};
int main(void) {
struct something obj;
obj.choices = &arr;
return 0;
}
When I compile this using a normal C compiler (gcc), I get no errors. However, I am compiling for the Z80, and it raises a ERROR (152) Operands are not assignment compatible
, which is described as:
An attempt was made to assign a value whose type cannot be promoted to the type of the destination.
I fail to understand how the types of &arr
and char *(*choices)[2]
could differ. What can I do to fix this ?
(I'm using the Zilog z80 compiler, which is part of ZDS 5.2.0)
It's probably some kind of weird compiler bug. This code compiles fine:
struct something {
char *** choices;
};
char * arr[2] = {"foo", "bar"};
int main(void) {
struct something obj;
obj.choices = &arr;
return 0;
}
And I'm afraid that it's the only workaround that is the most compatible with original idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With