1

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?

Kaiyaha
  • 408
  • 2
  • 8

2 Answers2

2

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.

ikegami
  • 343,984
  • 15
  • 249
  • 495
1

The TCHAR can be either a char or WCHAR based on the platform, and the WCHAR will always be a 16-bit Unicode character, wchar_t.

User
  • 131
  • 9
  • Will I have portable code if I specify `tchar` instead of `char`? – Kaiyaha Oct 30 '20 at 11:09
  • 1
    @Kaiyaha no. Just avoid all those TCHAR and wchar_t and use UTF-8 everywhere. It's possible in Windows right now: [What is the Windows equivalent for en_US.UTF-8 locale?](https://stackoverflow.com/a/63454192/995714) – phuclv Oct 30 '20 at 12:07