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.
Has anyone defined an array of struct inside another struct with C51? I can find no reference document prohibiting it. Yet, when I try to compile following fragment:
#include <stdio.h> struct s1 { int m1a; int m1b; }; struct s2 { int m2c; struct s1 m2d[2]; }; struct s2 e = { 1, { 2, 3 }, { 4, 5 } }; void main(void) { for(;;) { printf("%d %d %d\n", e.m2c, e.m2d[0].m1a, e.m2d[0].m1b); } }
which I expect to create one structure e, of 5 ints, and initialize it as follows:
e +---------------+ | m2c | | +---+ | | | 1 | | | +---+ | | m2d[0] | | +-----------+ | | | m1a m1b | | | | +---+---+ | | | | | 2 | 3 | | | | | +---+---+ | | | +-----------+ | | m2d[1] | | +-----------+ | | | m1a m1b | | | | +---+---+ | | | | | 4 | 5 | | | | | +---+---+ | | | +-----------+ | +---------------+
C51 aborts on the definition of e:
11 struct s2 e = { 1, 12 { 2, 3 }, 13 { 4, 5 } *** ERROR C242 IN LINE 13 OF TESTMENU05.C: 'struct': too many initializers
Ideas?
============================================================ Gary Lynch | To send mail, no$pam in domain name lynchg@no$pam.com | must be changed to stacoenergy.