The ## (double number sign) operator concatenates two tokens in a macro invocation (text and/or arguments) given in a macro definition.
If a macro XY was defined using the following directive:
#define XY(x,y) x##y
the last token of the argument for x is concatenated with the first token of the argument for y.
Use the ## operator according to the following rules:
The following examples demonstrate the use of the ## operator:
#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 |
Related information