We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I get syntax error for valid C-syntax. It seems like the compiler thinks that the initializer of the variable must come from a constant expression whereas a variable assignment should be accepted as well.
A workaround is to make the declaration separate from the initialization.
Same problem in both C51 and CX51.
foo_t f = {1, 2}; foo_t A[10] = { { 1, 2 } }; void foo(int i, foo_t* foo_p) { foo_t x = f; // C51: error C248: aggregate initialization needs curly braces foo_t y = A[i]; // C51: error C248: aggregate initialization needs curly braces foo_t z = foo_p[i]; // C51: non-address/-constant initializer foo_t w; w = foo_p[i]; // OK }