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,301
  • 5
  • 35
  • 61

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
  • 104,737
  • 16
  • 128
  • 186
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
  • 78,684
  • 20
  • 152
  • 166