I'm taking a look at an application that defines a large set of constant arrays. What really confuses me is the use of two pound signs next to each other in a macro. For example:
#define r0(p,q,r,s) 0x##p##q##r##s
What do those two pound signs mean?
The double-number-sign or token-pasting operator (##), which is sometimes called the merging or combining operator, is used in both object-like and function-like macros. It permits separate tokens to be joined into a single token, and therefore, can't be the first or last token in the macro definition.
The number-sign or "stringizing" operator (#) converts macro parameters to string literals without expanding the parameter definition. It's used only with macros that take arguments.
You can't have recursive macros in C or C++.
If you define a macro twice like that, the compiler should at least give you warning, if not an error. It is an error. §6.10.
##
provides a way to concatenate actual arguments during macro expansion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With