Distinguish between TCHAR and _TCHAR

What are the different differences between the two TCHAR and _TCHAR defined in the tchar.h Windows header? Explain with examples. Briefly describe the scenarios where you would use TCHAR as opposed to _TCHAR in your code. (10 points)

+7
windows unicode tchar
source share
2 answers

Found my answer here:

MSDN Forums β†’ Visual Studio Development Center β†’ TCHAR vs _TCHAR

TCHAR and _TCHAR are identical, though, since TCHAR does not have Microsoft emphasizes that Microsoft cannot reserve it as a keyword (imagine if you had a variable called TCHAR. Happens). Therefore, TCHAR will not be #defined if language extensions are disabled (/ Za).

TCHAR is defined in winnt.h (which you will get when you #include), as well as tchar.h under / Ze. _TCHAR is only available in tchar.h (which is also #defines _TSCHAR and _TUCHAR). These are unsigned / signed variants of the usual TCHAR data type.

+7
source share

In addition to what @RussC said, TCHAR used by the Win32 API and is based on the definition of UNICODE , while _TCHAR used by the C runtime and is based on the definition of _UNICODE , UNICODE and _UNICODE are usually defined / omitted together, making TCHAR and _TCHAR interchangeable, but this not a requirement. They are semantically separated for use by various structures.

+9
source share

All Articles