DEFINE-hash-multiple
Synopsis
Multiple # or ## operators in a macro definition.
Enabled by default
Yes
Severity/Certainty
Medium/Low

Full description
The order of evaluation associated with both the # and ## preprocessor operators is unspecified. Avoid this problem by having only one occurrence of either operator in any single macro definition (i.e. one #, or one ##, or neither). This check is identical to MISRAC2004-19.12, MISRAC++2008-16-3-1.
Coding standards
- MISRA C:2004 19.12
(Required) There shall be at most one occurrence of the # or ## preprocessor operators in a single macro definition.
- MISRA C++ 2008 16-3-1
(Required) There shall be at most one occurrence of the # or ## operators in a single macro definition.
Code examples
The following code example fails the check and will give a warning:
#define C(x, y) # x ## y /* Non-compliant */
The following code example passes the check and will not give a warning about this issue:
#define A(x) #x /* Compliant */