For my c11 project I get false positives on MISRA 10.3 (The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category) when assigning true or false to a boolean variable.
I suppose this is because stdbool.h defines:
#define true 1
#define false 0
Which makes true and false essentially signed integers.
Here some example code:
#include<stdbool.h>booldummy_func(intval){boolmy_bool;if(val>10){my_bool=true;// Triggers warning for MISRA 10.3}else{my_bool=false;// Triggers warning for MISRA 10.3}returnmy_bool;}
I am running cppcheck from the GUI and I cannot find a setting for which c standard I use - in case that is the problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For my c11 project I get false positives on MISRA 10.3 (The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category) when assigning true or false to a boolean variable.
I suppose this is because stdbool.h defines:
Which makes true and false essentially signed integers.
Here some example code:
I am running cppcheck from the GUI and I cannot find a setting for which c standard I use - in case that is the problem.
After writing the above I did find the setting for C-standard in the GUI. However, the problem still remains.
Last edit: Andreas 2023-10-25