![]() |
![]() |
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)
{
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |