## Preprocessor Macro Operator
Use the ## operator according
to the following rules:
- The ## operator cannot be
the very first or very last item in the replacement list
of a macro definition.
- The last token of the item in front of the
## operator is concatenated with first
token of the item following the ##
operator.
- Concatenation takes place before any
macros in arguments are expanded.
- If the result of a concatenation is a
valid macro name, it is available for further replacement
even if it appears in a context in which it would not
normally be available.
- If more than one ##
operator and/or #
operator appears in the replacement list of a macro
definition, the order of evaluation of the operators is
not defined.
The following examples demonstrate the use of
the ## operator:
Sample Preprocessor Macro Definitions |
#define ArgArg(x, y) x##y
#define ArgText(x) x##TEXT
#define TextArg(x) TEXT##x
#define TextText TEXT##text
#define Jitter 1
#define bug 2
#define Jitterbug 3 |
Invocation
|
Result
of Macro Expansion |
ArgArg(lady, bug) |
"ladybug" |
ArgText(con) |
"conTEXT" |
TextArg(book) |
"TEXTbook" |
TextText |
"TEXTtext" |
ArgArg(Jitter, bug) |
3 |
Preprocessor
Directives
Preprocessor
Macros
Preprocessor Macro
Operators
#define Preprocessor
Directive