![]() |
![]() |
3408 | ![]() |
||||
![]() | |||||||
| Declarations and Definitions | |||||||
An object or function is being defined with external linkage but no previous declaration has been encountered. When an item has external linkage, it can usually be assumed that it will be accessed in more than one translation unit. In order to ensure consistency between definition and usage, it is conventional to implement a single declaration located in a header file and for that header file to be included in the translation unit where the item is defined and every translation unit where it is used.
/*PRQA S 2017,3211,3603 ++*/
extern int gv1 = 0; /* Message 3408 */
extern int gv2; /* Message 3447 */
int gv2 = 0;
extern void foo1(void) /* Message 3408 */
{
}
extern void foo2(void); /* Message 3447 */
extern void foo2(void)
{
}
MISRA-C:2004 Rules applicable to message 3408:
| Rule 8.8 (Required) | An external object or function shall be declared in one and only one file. |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |