![]() |
![]() |
3121 | ![]() |
||||
![]() | |||||||
| Constants | |||||||
A floating constant has been used. It may be better to define the constant as a macro or a "const" qualified object. Message 3121 will not be generated in these contexts and the definition can be located where it can more easily be reviewed and maintained - rather than buried within executable code. This is particularly important for maintainability if the same constant is reused in several places. Giving the constant a name may also improve readability. This message will not be generated for the constants '0.0' and '1.0' because of their common use in initializations, For example:
/*PRQA S 1305,2017,2211,2213,3205,3207,3211,3223,3408,3602,3604,3674 ++*/
#define FOUR 4.4
double ga = 2.2; /* Message 3121 */
const double gb = 3.3;
static double sa = 4.4; /* Message 3121 */
static const double sb = 5.5;
extern void foo(void)
{
double a = 0.0; /* */
double b = 1.0; /* */
double c = 2.2; /* Message 3121 */
double d = 3.3; /* Message 3121 */
double e = FOUR; /* */
const double cc = 2.2; /* */
const double cd = 3.3; /* */
const double ce = FOUR; /* */
double a1[] = { 1.0, 0.0, 0.0 }; /* */
double a2[] = { 2.2, 0.0, 0.0 }; /* Message 3121 */
}
No MISRA C:2012 Rules applicable to message 3121
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |