MISRA Discussion Forums
Clarification of rule 2.5 - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.1 A standard C environment (https://forum.misra.org.uk/forumdisplay.php?fid=156)
+---- Thread: Clarification of rule 2.5 (/showthread.php?tid=1168)



Clarification of rule 2.5 - anuj1085 - 23-03-2015

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.


Re: Clarification of rule 2.5 - misra-c - 01-04-2015

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.