Hello,
I'm using cppcheck in a Iar project where we use sometimes the #pragma and cppcheck (we run 1.67) seems to not correctly manage them. I saw that problem was already rised sometime ago but I don't understand how it was solved.
thanks
Michele
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
3: You could use -D and -U at the command line also. How you do that depends on how the iar macros are defined, what -I you use, and if you want to check more than 1 ifdef configuration.
Last edit: Daniel Marjamäki 2015-11-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
thanks a lot for the support. I did a fast try with my batch but it was not working but I didn't have time to investigate. I will test better on monday. Thanks again and have a nice weekend
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm using cppcheck in a Iar project where we use sometimes the #pragma and cppcheck (we run 1.67) seems to not correctly manage them. I saw that problem was already rised sometime ago but I don't understand how it was solved.
thanks
Michele
hello,
is there no solution to this problem? My other option is to pre-process the files and remove the pragma ..
Thanks for the support
Michele
can you describe the problem further? a small example code with a #pragma that reproduce the problem would be very nice.
Hello,
Thanks a lot for the support.
here it is an example
void reset( void )
{
U16 zIndex;
U16* pzDebug;
pzDebug = &MyDebug.debug0;
for ( zIndex = 0U; zIndex < 15; zIndex++ )
{
MISRAC_DISABLE
pzDebug[zIndex] = (U16)0;
MISRAC_ENABLE
}
}
and the output of cppcheck
warning: cppchecker:style,unreadVariable,Variable 'pzDebug' is assigned a value that is never used."
The 2 defines are defined in the current way (I'm sorry but I don't know why the font is so big!):
/
* IAR MisraC checker Enable/Disable
*/
define MISRAC_DISABLE _Pragma ("diag_suppress=Pm001,Pm002,Pm003")
define MISRAC_ENABLE _Pragma ("diag_default=Pm001,Pm002,Pm003")
ok.
Cppcheck will not handle this internally. You need to configure it somehow.
There are many choices for how to configure this.
1: You can write and use an iar.cfg file that explains iar extensions.
Here is an example iar.cfg
You can use it with a "--library=iar" like this:
$ cppcheck --library=iar test1.c
2: You can write an extra header for Cppcheck where IAR macros are defined
iar.h:
Then use "--include=iar.h" like this:
$ cppcheck --include=iar.h test1.c
3: You could use -D and -U at the command line also. How you do that depends on how the iar macros are defined, what -I you use, and if you want to check more than 1 ifdef configuration.
Last edit: Daniel Marjamäki 2015-11-06
Hello,
thanks a lot for the support. I did a fast try with my batch but it was not working but I didn't have time to investigate. I will test better on monday. Thanks again and have a nice weekend
Hello,
today I tested it and it works perfectly.
thank you very much for the support.
Michele