Menu

suppression in macros not working

2024-10-06
2024-10-15
  • Richard Smith

    Richard Smith - 2024-10-06

    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.

     
  • Richard Smith

    Richard Smith - 2024-10-06

    Oops sorry that should be:

    #define MSG_UPCAST(ptr) /* cppcheck-suppress misra-c2012-11.3 */ ((msg_t *) (ptr))

     
  • Richard Smith

    Richard Smith - 2024-10-06

    But I still get the deviation message

     
  • Daniel Marjamäki

    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?

     
  • Richard Smith

    Richard Smith - 2024-10-15

    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.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.