Вопрос

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?

Это было полезно?

Решение

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.

Другие советы

_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.

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top