...
Wiki Markup |
---|
The {{\##}} preprocessing operator is used to merge two tokens into one while expanding macros. This is called token pasting or token concatenation. When a macro is expanded, the two tokens on either side of each ## operator are combined into a single token, which replaces the {{\##}} and the two original tokens in the macro expansion \[[FSF 052005|AA. Bibliography#FSF 05]\]. |
...
Wiki Markup |
---|
Parameters are not replaced inside string constants, but you can use the {{\#}} preprocessing operator instead. When a macro parameter is used with a leading {{\#}}, the preprocessor replaces it with the literal text of the actual argument, converted to a string constant \[[FSF 052005|AA. Bibliography#FSF 05]\]. |
...
The following definition for static_assert()
from guideline 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__
.
...
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 PRE01-C. Use parentheses within macros around parameter names.
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Other Languages
Related Guidelines
This rule appears in the C++ Secure Coding Standard as : PRE05-CPP. Understand macro replacement when concatenating tokens or performing stringification.
Bibliography
Wiki Markup |
---|
\[[FSF 052005|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 082008|AA. Bibliography#Saks 08]\] |
...