trying to use pc-lint with MISRA 2012 I have tried to change in stdbool
#define bool _Bool //typedef _Bool bool;
makes no difference
any suggestions?
I get the below type of 'report' all over the place.
bool bIsFahrenheit = false; ^ ..\Src\statemachine.c(34,0): Note 970: Use of modifier or type '_Bool' outside of a typedef [MISRA 2012 Directive 4.6, advisory] ^ ..\Src\statemachine.c(34,0): Note 9075: external symbol 'bIsFahrenheit' defined without a prior declaration [MISRA 2012 Rule 8.4, required] #... ve -e921 */(_Bool) 0/*lint -restore */ ^ ..\Src\statemachine.c(34,0): Note 970: Use of modifier or type '_Bool' outside of a typedef [MISRA 2012 Directive 4.6, advisory]
#define bool _Bool //typedef _Bool bool; typedef bool bool_t;
was that what you ment? if so, it makes it worse
..\Src\statemachine.c(69,0): Note 970: Use of modifier or type '_Bool' outside of a typedef [MISRA 2012 Directive 4.6, advisory] bool_t align_mode = false; ^ ..\Src\statemachine.c(70,0): Note 9075: external symbol 'align_mode' defined without a prior declaration [MISRA 2012 Rule 8.4, required] #... e -e921 */(_Bool) 0/*lint -restore */ ^ ..\Src\statemachine.c(70,0): Note 970: Use of modifier or type '_Bool' outside of a typedef [MISRA 2012 Directive 4.6, advisory] if (align_mode == false) #... t -save -e921 */(_Bool) 0/*lint -restore */ ^ ..\Src\statemachine.c(84,0): Note 970: Use of modifier or type '_Bool' outside of a typedef [MISRA 2012 Directive 4.6, advisory] if (align_mode == false) ^ ..\Src\statemachine.c(84,0): Info 731: Boolean argument to equal/not equal
Hello Erik,
Have you used this tool to play around with your code:
gimpel-online.com/.../genPage.py
When you put your code in there, it links the error message pages: gimpel-online.com/MsgRef.html In that entry it says: "You may enable this message and then suppress the message for individual types to obtain special effects. For example the following will enable the message for all but bool." +e970 -esym(970,bool)
=====
As for the "MISRA 2012 Directive 4.6, advisory" line in the error message, there is a good discussion here:
stackoverflow.com/.../does-misra-c-2012-say-not-to-use-bool
In that page they say: "Directive 4.6 says "typedefs that indicate size and signedness should be used in place of the basic numerical types"."
Also in that page, one of the posters disagrees with Gimpel's interpretation of Directive 4.6. You might want to check with Gimpel on their forum about this.
Vaguely relevant links to promote cross-linky-ness
Modifications that may be needed to the default lint config file. You might have to make your own tweaks as well:
www.keil.com/.../misraCompliance5.html
www.keil.com/.../coreMISRA_Exceptions_pg.html
You can set the ARM Compiler 6 to emit "MISRA compatible" warnings. See:
http://www.keil.com/support/man/docs/uv4/uv4_dg_armclang_cmp.htm
Discussions at
http://www.keil.com/forum/24035/
http://www.keil.com/forum/63388/