![]() |
![]() |
2022 | ![]() |
||||
![]() | |||||||
| Declarations and Definitions | |||||||
This is a tentative definition and according to the ISO:C Standard, the object will automatically be initialized to zero. In practice, some compilers do not conform to the C standard and objects defined with a tentative definition are not necessarily initialized. It may therefore be appropriate to ensure that all objects with linkage are defined with explicit initialization. For example:
/*PRQA S 1306,3120,3207,3210,3211,3408,3447 ++*/
extern int ea; /* Declaration */
int eb = 5; /* Explicit definition */
int ec; /* Message 2022 Tentative definition -> definition with implicit initialization to zero */
int ed; /* Message 2021 Tentative definition -> declaration */
int ed; /* Message 2021 Tentative definition -> declaration */
int ed = 5; /* Explicit definition */
int ee; /* Message 2021 Tentative definition -> declaration */
extern int ee = 5; /* Explicit definition */
static int sa; /* Message 2022 Tentative definition -> definition with implicit initialization to zero */
static int sb = 5; /* Explicit definition */
static int sc; /* Message 2022 Tentative definition -> definition with implicit initialization to zero */
static int sd; /* Message 2021 Tentative definition -> declaration */
static int sd; /* Message 2021 Tentative definition -> declaration */
static int sd = 5; /* Explicit definition */
static int se; /* Message 2021 Tentative definition -> declaration */
static int se = 5; /* Explicit definition */
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |