cwindowstypeswchartchar

What is TCHAR and how does it differ from WCHAR?


This question should've had an answer nowadays here, but there is nothing explaining what exactly TCHAR is on stackoverflow (all I found is an explanation of the difference between TCHAR and _TCHAR).

All I know is that TCHAR and _TCHAR are considered to be the same and on some platforms TCHAR may be the same as WCHAR. But all that is just a presumption.

What is TCHAR and how does it differ from WCHAR?


Solution

  • TCHAR is either char or wchar_t depending on whether UNICODE is defined or not.

    Using TCHAR and TCHAR-based types allow a library to work with programs that define UNICODE and programs that don't alike.