[previous] MISRA-C:2004  Rule  8.9:  (Required) [next] An identifier with external linkage shall have exactly one external definition.
Behaviour is undefined if an identifier is used for which multiple definitions exist (in different files) or no definition exists at all. Multiple definitions in different files are not permitted even if the definitions are the same, and it is obviously serious if they are different, or initialise the identifier to different values.

Example Code:


#include "misra.h"
#include "m2cmex.h"

S16 obj_0809a = 3;
S16 obj_0809a = 4;               /* MISRA Violation */


S16 obj_0809b = 1;               /* MISRA Violation - duplicate definition in main.c */

extern S16 test_0809(void)       /* MISRA Violation - duplicate definition in main.c */
{
    return 1;
}


QAC messages that encompass this guideline:

0630 [U] More than one definition of '%s' (with external linkage).
1509 '%1s' has external linkage and has multiple definitions.


Related rules:

Rule  1.2 No reliance shall be placed on undefined or unspecified behaviour.



(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