Question:
How to suppress Misra rule checking for a particular file or an error code?
Answer:
We can suppress all the MISRA rule checking for particular file or function by doing the following:
#if defined(_MISRA_RULES)
#pragma diag(push)
#pragma diag(suppress:misra_rules_all)
#endif /* _MISRA_RULES */
void my_function_using_macros(void)
{
}
#if defined(_MISRA_RULES)
#pragma diag(pop)
#endif /* _MISRA_RULES */
For example,If we want to suppress a particular misra rule(12.7),then we can use "#pragma diag(suppress:misra_rule_12_7:"
Please note that all errors cannot be suppressed using the above option.
If we want to suppress a particular error that should contain a "{D}" prefix in the generated error code.
For example "cc1234: {D} error".