Token pasting
suggest changeThe ## 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents