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

jnmpg1623jnmpg1623 Posts: 3

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 Answer

Answers

  • jnmpg1623jnmpg1623 Posts: 3

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

  • jnmpg1623jnmpg1623 Posts: 3

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

  • jeangabejeangabe Posts: 2

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

  • jeangabejeangabe Posts: 2

    solution:
    simply put a pragma in the macro:

    #define CALC_INIT(val) \
    _Pragma("parasoft-suppress MISRAC2012-RULE_14_3-i 'JtemS34884' ") \
    ( ((val) < THRESH) ? THRESH : (val) )
    
Sign In or Register to comment.