MISRA.DEFINE.SHARP# or ## operator in a macro definition. MISRA C 2012 Rule 20.10: The # and ## preprocessor operators should not be usedC90 [Unspecified 12; Undefined 51, 52], C99 [Unspecified 25; Undefined 3, 88, 89] Category: Analysis Analysis: Decidable, Single Translation Unit Applies to: C90, C99 RationaleThe order of evaluation associated with multiple #, multiple ## or a mix of # and ## preprocessor operators is unspecified. In some cases it is therefore not possible to predict the result of macro expansion. The use of the ## operator can result in code that is obscure. Note: Rule 1.3 covers the undefined behaviour that arises if either:
See alsoRule 20.11 MISRA-C 2004 Rule 19.13 (advisory): The # and ## operators should not be used.[Unspecified 12] There is an issue of unspecified order of evaluation associated with the # and ## preprocessor operators. Compilers have been inconsistent in the implementation of these operators. To avoid these problems do not use them. MISRA-C++ 2008 Rule 16-3-2 (advisory): The # and ## operators should not be used.[Unspecified 16.3.2(2), 16.3.3(3), Undefined 16.3.2(2), 16.3.3(3)] RationaleThe order of evaluation associated with both the # and ## preprocessor operators is unspecified. Compilers have been known to implement these operators inconsistently, therefore, to avoid these problems, do not use them. Example#define A(Y) #Y // Non-compliant #define A(X,Y) X##Y // Non-compliant |