My understanding of the C language is that the same identifier cannot be reused.
That's correct, but only within the same name space (not the same as a C++ namespace). There are five listed name spaces in C:
- Label names (such as cases and goto labels).
- Structure, union, or enum tags.
- Structure or union members.
- Typedef names;
- Everything else.
With those name spaces in mind, it's easy to understand why the following is legal:
typedef struct foo { int foo; } foo;
In your code, the typedef error and the macro error are in different name spaces (the typedef falls under #4 and the macro under #5), so there's no direct conflict.
deceptikon
Challenge Accepted
3,445 posts since Jan 2012
Reputation Points: 822
Solved Threads: 473
Skill Endorsements: 57
Question Answered as of 9 Months Ago by
deceptikon