![]() |
|
MISRA-C:2004 Rule 5.5: (Advisory) |
|
||||
![]() | |||||||
While the compiler can understand this and is in no way confused, the possibility exists for the user to incorrectly associate unrelated variables with the same name. One example of this confusion is having an identifier name with internal linkage in one file and the same identifier name with external linkage in another file.
Example Code:
#include "misra.h"
#include "m2cmex.h"
static S16 obj_0505a = 0; /* MISRA Violation - Declared with external linkage in main.c */
static S16 obj_0505c = 0; /* MISRA Violation - Declared with internal linkage in main.c */
static S16 test_0505a(void);
extern S16 test_0505( void )
{
return test_0505a() + obj_0505a + obj_0505c;
}
static S16 test_0505a(void)
{
S16 obj_0505b; /* MISRA Violation - Declared with internal linkage in main.c */
S16 obj_0505d = get_s16(); /* MISRA Violation - Declared with internal linkage in main.c */
S16 obj_0505e = get_s16();
obj_0505b = s16a + obj_0505c + obj_0505d + obj_0505e;
return obj_0505a + obj_0505b;
}
QAC messages that encompass this guideline:
| 1525 | Object/function with external linkage has same identifier as another object/function with internal linkage. |
| 1526 | Object with no linkage has same identifier as another object/function with external linkage. |
| 1527 | Object/function with internal linkage has same identifier as another object/function with internal linkage. |
| 1528 | Object with no linkage has same identifier as another object/function with internal linkage. |
| 1529 | Object with no linkage has same identifier as another object with static storage duration but no linkage. |
|
||
(c) The Motor Industry Research Association, 2004
|
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |