MISRA Discussion Forums
Macros with not distinct parameters names: raise rule 5.4? - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forum-4.html)
+--- Forum: MISRA C:2012 guidelines (https://forum.misra.org.uk/forum-21.html)
+---- Forum: 8.5 Identifers (https://forum.misra.org.uk/forum-160.html)
+---- Thread: Macros with not distinct parameters names: raise rule 5.4? (/thread-1349.html)



Macros with not distinct parameters names: raise rule 5.4? - ggoulas - 12-06-2017

Hi,

Should the following raise MISRA C:2012 rule 5.4 ?

#define MACRO(MACRO) MACRO

and more generally:
#define X123456789_123456789_123456789_AA(X123456789_123456789_123456789_AB) f(X123456789_123456789_123456789_AB)

I thought that not since there is no confusion when parameters are substituted because the macro is not active.
Is it right?
Many thanks!


Re: Macros with not distinct parameters names: raise rule 5.4? - misra-c - 21-09-2017

Your example is compliant with rule 5.4. This rule only requires that the macro being defined has a name that is distinct from
  • the names of other macros that are currently defined
  • the names of macro parameters in other macros that are currently defined.