Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clarification of rule 2.5
The unused macro in "header" files are also a violation of this rule. explanation below:

#define abc 10

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

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.
Posted by and on behalf of the MISRA C Working Group

Forum Jump:

Users browsing this thread: 1 Guest(s)