C preprocessor Literal Construction C preprocessor Literal Construction c c

C preprocessor Literal Construction


Try this:

#define WIDEN_(exp)   L##exp#define WIDEN(exp)    WIDEN_(exp)#define TITLE         "Title"#define W_TITLE       WIDEN(TITLE)

You need to force an expansion through an intermediate macro to get what you're looking for.

#include <stdio.h>#define WIDEN_(exp)   L##exp#define WIDEN(exp)    WIDEN_(exp)#define TITLE         "Title"#define W_TITLE       WIDEN(TITLE)int main(int argc, char *argv[]){    printf("%s\n", TITLE);    wprintf(L"%ls\n", W_TITLE);    return 0;}

Result:

TitleTitle