.TH "##" "" "" "Preprocessing Operator"
.II "token pasting"
.II "operator, token-pasting"
.II "token-pasting operator"
.PC "Token-pasting operator"
.PP
The preprocessing operator
.B ##
can be used in both object-like and function-like macros.
When used immediately before or immediately after an element in
the macro's replacement list,
.B ##
joins the corresponding preprocessor token with its neighbor.
This is sometimes called \*(QLtoken pasting\*(QR.
.PP
As an example of token pasting, consider the macro:
.DM
	#define printvar(number) printf("%s\en", variable ## number)
.DE
.PP
When the preprocessor reads the following line
.DM
	printvar(5);
.DE
.PP
it substitutes the following code for it:
.DM
	printf("%s\en", variable5);
.DE
.PP
The preprocessor throws away all white space both before and after the
.B ##
operator.
This gives you an easy way to print any one of a set of strings.
.PP
.B ##
must not be used as the first or last entry in a
replacement list.
All instances of the
.B ##
operator are resolved before further macro replacement is performed.
.PP
For more information on object-like and function-like macros, see
.BR #define .
.SH "See Also"
.Xr "#" _23
.Xr "#define," _23define
.Xr "C preprocessor" c_preproc
.br
\*(AS, \(sc6.8.3.3
.SH Notes
Some C implementations allow token pasting by using an empty comment.
For example:
.DM
	variable/**/number
.DE
.PP
The \*(CO C compiler does not recognize this ``trick'' because
it is not consistent with the Kernighan & Ritchie standard for C,
which states that a comment is white space and therefore is a token separator.
In any event, token pasting should always be performed with
.BR ## .
.PP
The
.B ##
operator may be used only within the replacement text of a preprocessor macro
definition.
.PP
The order of evaluation of multiple
.B ##
operators is unspecified.
