![]() |
![]() |
3131 | ![]() |
||||
![]() | |||||||
| Constants | |||||||
An integer constant has been used to define the size of a bit-field. If the size of the bit-field is also used in other contexts it may be better to define the constant as a macro or an enum constant. Message 3131 will not be generated in these contexts and the macro or enum constant can be reused wherever needed. Giving the constant a name may also improve readability. Notice also that message 3131 will not be generated on a bit-field defined with a width of "1". For example:
/*PRQA S 553,2017,2213,3602,3621 ++*/
#define NBITS 3
enum {FOUR = 4};
struct ST
{
unsigned int a:1; /* OK */
unsigned int b:2; /* Message 3131 */
unsigned int c:NBITS; /* OK */
unsigned int d:FOUR; /* OK */
};
No MISRA C:2012 Rules applicable to message 3131
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 |