Token pasting

suggest change

The ## operator pastes two preprocessing tokens into one. For example, front##back yields frontback. A well-known example is Win32’s <tchar.h> header. In standard C, L"string" is a wide string literal. The Windows headers let a program select wide or narrow literals by defining UNICODE. The wide branch is written like this:

#ifdef UNICODE
#define TEXT(x) L##x
#endif

When UNICODE is defined, TEXT("hello, world") pastes L to the argument and produces L"hello, world". The real header also defines TEXT(x) as x when UNICODE is not defined. Pasting works here because the argument is one string-literal token. TEXT(hello) would produce the identifier Lhello, not a wide string.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents