...
The following definition for static_assert()
from guideline recommendation DCL03-C. Use a static assertion to test the value of a constant expression uses the JOIN()
macro to concatenate the token assertion_failed_at_line_
with the value of __LINE__
.
...
Code Block | ||
---|---|---|
| ||
#define JOIN(x, y) x ## y |
because Because the __LINE__
is not expanded, and the character array is subsequently named assertion_failed_at_line___LINE__
.
...
Note also that macro parameters cannot be individually parenthesized when concatenating tokens using the ##
operator, converting macro parameters to strings using the #
operator, or concatenating adjacent string literals. This is an exception, PRE01-EX2, to guideline recommendation PRE01-C. Use parentheses within macros around parameter names.
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
CERT C++ Secure Coding Standard: PRE05-CPP. Understand macro replacement when concatenating tokens or performing stringification
ISO/IEC 9899:1999 Section 6.10.3, "Macro replacement," Section 6.10.3.3, "The ##
operator," Section 6.10.3.2, "The #
operator," Section 6.10.3.4, "Rescanning and further replacement," and Section 6.10.8, "Predefined macro names"
Bibliography
Wiki Markup |
---|
\[[FSF 2005|AA. Bibliography#FSF 05]\] Section 3.4, "[Stringification|http://gcc.gnu.org/onlinedocs/cpp/Stringification.html]" and Section 3.5, "[Concatenation|http://gcc.gnu.org/onlinedocs/gcc-4.3.0/cpp/Concatenation.html#Concatenation]"
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.10.3, "Macro replacement," Section 6.10.3.3, "The {{\##}} operator," Section 6.10.3.2, "The {{\#}} operator," Section 6.10.3.4, "Rescanning and further replacement," and Section 6.10.8, "Predefined macro names"
\[[Saks 2008|AA. Bibliography#Saks 08]\] |
...