22-04-2008, 08:25 AM
Hi,
Suppose we have 2 c source code files (cfile1.c and cfile2.c) and 2 header files (hfile1.h and hfile2.h).
In hfile1.h I can #define BILL to be something and then #include hfile1.h in cfile1.c.
Now in hfile2.h I can #define BILL to be something else and #include hfile2.c in cfile2.c.
All this will compile and link without warnings.
The fact is I have 2 macros with the same name but with different definitions.
This is unwise and I can't see a MISRA rule that would forbid such code.
Am I mistaken?
Cheers,
BILL.
Suppose we have 2 c source code files (cfile1.c and cfile2.c) and 2 header files (hfile1.h and hfile2.h).
In hfile1.h I can #define BILL to be something and then #include hfile1.h in cfile1.c.
Now in hfile2.h I can #define BILL to be something else and #include hfile2.c in cfile2.c.
All this will compile and link without warnings.
The fact is I have 2 macros with the same name but with different definitions.
This is unwise and I can't see a MISRA rule that would forbid such code.
Am I mistaken?
Cheers,
BILL.