This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Initializing array of structs

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

Parents
  • Thank you both for your fast replies.

    Actually you are right, it should have comes as no surprise at all. In the mean time between posting and writing this post, I pulled out my good ol' Kernighan&Richie and found that I was wrong.

    However, this method works with the GNU C compiler, so that is what confused me.

    Thank you once again.

    Best regards
    Henrik

Reply
  • Thank you both for your fast replies.

    Actually you are right, it should have comes as no surprise at all. In the mean time between posting and writing this post, I pulled out my good ol' Kernighan&Richie and found that I was wrong.

    However, this method works with the GNU C compiler, so that is what confused me.

    Thank you once again.

    Best regards
    Henrik

Children