I have a series of global events that are used within a C program in different areas. Any area can create an arbitrary event to hook and handle appropriately.
I need a way to define a variable amount of arbitrary constants that are unique and global. Sanitation aside, this is approximately what I was hoping would work:

event\_handler.h

```
extern int last_event_ = 0;

#define NEW_EVENT() (last_event_++)

```

first\_handler.h

```
#define FIRST_EVENT NEW_EVENT()

```

second\_handler.h

```
#define SECOND_EVENT NEW_EVENT()

```

main.c

```
#include "first_handler.h"
#include "second_handler.h"

int main(int argc, char **argv) {
    printf("Second event number: %d\n", SECOND_EVENT);
    printf("Second event number: %d\n", SECOND_EVENT);
    return 0;
}

```

This does not work as expected however because of the way macros are executed. Causing it to print out 0 then 1 when it should be printing out the same number.