TEXT vs. _TEXT vs. _T, and UNICODE vs. _UNICODE

Raymond Chen

So what’s with all these different ways of saying the same thing?

There’s actually a method behind the madness.

The plain versions without the underscore affect the character set the Windows header files treat as default. So if you define UNICODE, then GetWindowText will map to GetWindowTextW instead of GetWindowTextA, for example. Similarly, the TEXT macro will map to L”…” instead of “…”.

The versions with the underscore affect the character set the C runtime header files treat as default. So if you define _UNICODE, then _tcslen will map to wcslen instead of strlen, for example. Similarly, the _TEXT macro will map to L”…” instead of “…”.

What about _T? Okay, I don’t know about that one. Maybe it was just to save somebody some typing.

0 comments

Discussion is closed.

Feedback usabilla icon