0

How does the TEXT("x") macro expand to L"x" if unicode is defined and "x" if unicode is not defined because when I try to compile the following code it says "error #1049: Syntax error in macro parameters."

#define T("x") "x"

int main()
{
}
user1232138
  • 5,451
  • 8
  • 37
  • 64

2 Answers2

2

Lookup the tchar.h header in your installation. You'd get something like the following:

#define __T(x)      L ## x

In Unicode mode, the above macro pastes an L and a string argument together. In ASCII mode, there is no prefix to paste so it goes simply as:

#define __T(x)      x

Note that you invoke this macro indirectly, via another macro -- _T() (with a single underscore) and pass a string literal as argument.

dirkgently
  • 108,024
  • 16
  • 131
  • 187
1
#define T("x") "x"

That defines a macro function T, and what would be a parameter named x if there weren't any quotes. You could try something like this instead:

#define T(x) #x
K-ballo
  • 80,396
  • 20
  • 159
  • 169