Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Rules Suppression Question, Source of a warning from a #define MACRO.

Options
jnmpg1623
jnmpg1623 Posts: 4

Question:
Can we place the suppression in the MACRO and will the Parasoft tool recognize it, and suppress the warning in consuming .c files?
We are struggling to get this construct to work. We want to be able to suppress the warnings from where the Macro is defined in the header file, instead of having to modify 1000's of .c files that use the Macro.

Background:

We are struggling to suppress warnings resulting from MACROs.

My question revolves around the Source of a warning from a #define MACRO.
We have gone through the deviation process and created the supression text.... /* parasoft-suppress MISRAC2012-RULE_14_3-i "JtemS#####" */

When used in the following manner, the warnings in the .c file where the Macro is used does not seem to be suppressed. Is there a way to suppress warnings from Macros at the source in the header file? The use case is Compile Time constant calculations....

.h file...
#define THRESH ((FLOAT)2.0)
#define CALC_INIT(val) ( ((val) < THRESH) ? THRESH : (val) )

.c file...
#include .h...
const FLOAT Array[4] = {
CALC_INIT(0,0),
CALC_INIT(1,0),
CALC_INIT(3,0),
CALC_INIT(4,0)
}

for instance should the following work... suppressing all warnings in any .c file that uses the MACRO?

#define CALC_INIT(val) ( ((val) < THRESH) ? THRESH : (val) /* parasoft-suppress MISRAC2012-RULE_14_3-i "JtemS34884" */ )

Best Answers

Answers

  • jnmpg1623
    jnmpg1623 Posts: 4
    Options

    I think i miss spoke.. i am really referring to "Violation suppression"

  • jnmpg1623
    jnmpg1623 Posts: 4
    Options

    Thanks for the information. It appears there is an option to keep comments after MACRO expansion. I will give it a try.

  • jeangabe
    jeangabe Posts: 2
    Options

    I have the same problem. Did it work @jnmpg1623?

  • jnmpg1623
    jnmpg1623 Posts: 4
    Options

    Using Compiler Option to leave comments post macro expansion, didn't work.

    The _Pragma approach did work.