31-10-2011, 01:06 PM
Hi.
I wonder whether there's any MISRA rule that forbids operations on bit fields?
The question came up as I received some code from another project which contains a bit field, several defines (e.g. #define ENABLE_XY 0x80) and (logical) operations on it (e.g. "if (bitfield | ENABLE_XY)").
However, my compiler implements inverse arrangement for bit fields and has no switch to change it, so the old code now produces wrong results.
But the old code has passed the MISRA check. Therefore my question is: Is that code just an example of "worst coding style" or should there be a MISRA rule which prevents the programmer from such carelessness?
Best regards,
mic
I wonder whether there's any MISRA rule that forbids operations on bit fields?
The question came up as I received some code from another project which contains a bit field, several defines (e.g. #define ENABLE_XY 0x80) and (logical) operations on it (e.g. "if (bitfield | ENABLE_XY)").
However, my compiler implements inverse arrangement for bit fields and has no switch to change it, so the old code now produces wrong results.
But the old code has passed the MISRA check. Therefore my question is: Is that code just an example of "worst coding style" or should there be a MISRA rule which prevents the programmer from such carelessness?
Best regards,
mic
<t></t>