-3

I know that the _T(x) macro converts a string literal to a unicode/multibyte string based on a define, however I find it very annoying that I must make a underscore and the parenthesis, it really confuses me, I'm not quiet fluent with macros so I don't know, is there a way to detect all string literals and convert them to a proper unicode/multibyte string?

NULL
  • 31
  • 1
  • 6

3 Answers3

1

No, there isn't a way to avoid the macro completely if you want your code to be portable on Windows. You can of course define your own macro like #define t(x) whatever_T_does if you want to save yourself some keystrokes, but this will probably anger future maintainers of your code.

John Zwinck
  • 223,042
  • 33
  • 293
  • 407
1

_T() and _TEXT() are C runtime macros, not Win32 macros. TEXT() (no underscore) is the Win32 macro. Even though they essentially do the same thing, you should use C runtime macros only with C functions, and Win32 macros with Win32 functions. Don't mix them.

Remy Lebeau
  • 505,946
  • 29
  • 409
  • 696
0

Do you really need the ability to compile for both multibyte and Unicode? You don't need any macro if you want multibyte. In a Unicode app it is easier to use L"literal string", which does not need the underscore or the parentheses.

ScottMcP-MVP
  • 10,152
  • 2
  • 14
  • 15