I'm trying to use the suppression in macro feature described here in cppcheck 2.15
https://trac.cppcheck.net/ticket/3537
We have a macro looks like the following:
#define MSG_UPCAST(ptr) ((msg_t *) (ptr))
Which is used like this:
send_msg(MSG_UPCAST(&msg), sizeof(msg))
This is a MISRA 11.3 deviation but we want to suppress it.
I've added the following to the macro
#define MSG_UPCAST(ptr) /* misra-c2012-11.3 */ ((msg_t *) (ptr))
But I still get the MISRA deviation message.
Oops sorry that should be:
#define MSG_UPCAST(ptr) /* cppcheck-suppress misra-c2012-11.3 */ ((msg_t *) (ptr))
But I still get the deviation message
We don't use the exact syntax suggested in ticket 3537. See manual at page 18: https://cppcheck.sourceforge.io/manual.pdf
The syntax is supposed to be something like:
// cppcheck-suppress-macro aaaa #define MACRO ... ... x = MACRO; // <- aaaa warnings are suppressed here
Does this work for you?
Yes. This works. Thank you. I was only looking at the commit message which only includes the track ticket so I thought that was the accepted format.
Log in to post a comment.
I'm trying to use the suppression in macro feature described here in cppcheck 2.15
https://trac.cppcheck.net/ticket/3537
We have a macro looks like the following:
#define MSG_UPCAST(ptr) ((msg_t *) (ptr))
Which is used like this:
send_msg(MSG_UPCAST(&msg), sizeof(msg))
This is a MISRA 11.3 deviation but we want to suppress it.
I've added the following to the macro
#define MSG_UPCAST(ptr) /* misra-c2012-11.3 */ ((msg_t *) (ptr))
But I still get the MISRA deviation message.
Oops sorry that should be:
#define MSG_UPCAST(ptr) /* cppcheck-suppress misra-c2012-11.3 */ ((msg_t *) (ptr))
But I still get the deviation message
We don't use the exact syntax suggested in ticket 3537. See manual at page 18:
https://cppcheck.sourceforge.io/manual.pdf
The syntax is supposed to be something like:
Does this work for you?
Yes. This works. Thank you. I was only looking at the commit message which only includes the track ticket so I thought that was the accepted format.