Tool/software: TI C/C++ Compiler
How if at all one can use the stdbool.h type and yet avoid MISRA checker error while trying to assign the result of a logical expression to the bool? The following would bombs out from line 3 with MISRA:
bool my_bool = false; my_bool = ! my_bool; my_bool = true && false; my_bool = !!(true && false);
Description Resource Path Location Type
#1393-D (MISRA-C:2004 10.1/R) The value of an expression of integer type shall not be implicitly converted to a different underlying type if it is not a conversion to a wider integer type of the same signedness ..... line 58 C/C++ Problem
This is in the provided stdbool.h with TI compiler, and I'm wondering how you could use that boolean type at all, as type always seems requires downcast in bit size?
#include <_ti_config.h> _TI_PROPRIETARY_PRAGMA("diag_push") _TI_PROPRIETARY_PRAGMA("CHECK_MISRA(\"-19.4\")") _TI_PROPRIETARY_PRAGMA("CHECK_MISRA(\"-19.11\")") #ifndef __cplusplus #define false 0 #define true 1 #define bool _Bool #if __TI_PROPRIETARY_STRICT_ANSI_MACRO && 199901L > __STDC_VERSION__ typedef unsigned char _Bool; #endif #endif /* !__cplusplus */ _TI_PROPRIETARY_PRAGMA("diag_pop")