MISRA Discussion Forums
Rule 13.2 - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA-C:2004 Exemplar Suite (https://forum.misra.org.uk/forumdisplay.php?fid=116)
+--- Thread: Rule 13.2 (/showthread.php?tid=1169)



Rule 13.2 - sundarn - 23-03-2015

typedef unsigned char bool;
bool sensor_status;

if(sensor_status) /*Rule 13.2*/
{
....
}
Is this a violation of rule 13.2 or could it be considered as effectively boolean ( Boolean by enforcement ).


Re: Rule 13.2 - misra-c - 01-04-2015

Whether type "bool" is "Boolean by enforcement" will depend on the requirements on your project. Assuming that it is decided that "bool" is to be treated as a boolean, you may then need to configure your tool to recognise the type as "effectively boolean" when the MISRA-C:2004 rules are checked.

Rule 13.2 is not violated if the type is treated as "effectively boolean".