MISRA Discussion Forums

Full Version: Clarification of rule 2.5
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The unused macro in "header" files are also a violation of this rule. explanation below:

File.h:
================
#define abc 10
================

Case1:
File1.c include file.h but does not use abc
Is this a violation.

Case2:
File1.c include file.h but does not use abc
File2.c includes file.h and uses abc
Is this a violation with respect to file1.c as it includes the header file but does not uses the macro.
Rule 2.5 is marked as having a "system" analysis scope. Rule 2.5 is only violated if the macro is used in none of the files in the system.

In Case1, the system only includes File1.c and does not use "abc". This is a violation of rule 2.5.

In Case2, the system contains both File1.c and File2.c. Since "abc" is used in one the files, there are no violations of rule 2.5.