Token Pasting with ## Operator

From RAD Studio
Jump to: navigation, search

Go Up to Defining And Undefining Macros Index

You can paste (or merge) two tokens together by separating them with ## (plus optional whitespace on either side). The preprocessor removes the whitespace and the ## operator, combining two separate tokens into one new token. You can use this to construct identifiers.

Given the definition

#define VAR(i, j) (i##j)

the call VAR(x, 6) expands to (x6).

The ## operator replaces the older nonportable method of using (i/**/j).