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.
Hello,
I have an array of structs, which I would like to initialize at startup, but to my surprise this gives me a compiler syntax error:
I do as follows:
typedef volatile struct Timer { BYTE byStatus; WORD wValue; void (code *pfHandler) (void); } T_TIMER; volatile T_TIMER g_aSWTimers[TIMER_NO_OF_TIMERS] = { { .byStatus = 0; .wValue = 0; .pfHandler = OnIgnoreSpeedTimer; }, { .byStatus = 0; .wValue = 0; .pfHandler = OnIgnoreFM1Timer; } };
And it gives me a warning saying
"TIMERINTS.C(108): error C141: syntax error near '.'"
Could anyone please point me in the right direction?
Thanking you all in advance.
Best regards Henrik
"However, this method works with the GNU C compiler, ..."
GNU C implements some of C99; "designated initializers" in this case.