when compiling: "Warning: Operation on `eventhead' may be Undefined"

Asked

Viewed 26 times

1

Hello, I’m trying to compile a code with this excerpt:

void D_PostEvent (event_t* ev)
{
    events[eventhead] = *ev;
    eventhead = (++eventhead)&(MAXEVENTS-1);
}

And I get the following warning:

d_main.c: In function `D_PostEvent': d_main.c:161: warning: operation on `eventhead' may be undefined

Does anyone know what I’m doing to keep that sign from showing up? Thank you!

  • Declare the variable eventhead as global or pass as parameter to the function.

1 answer

0

I decided to write like this: eventhead = (eventhead+1)&(MAXEVENTS-1);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.