Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between TCHAR and WCHAR?

Tags:

c++

winapi

I've opened winnt.h header file and found there this two lines:

typedef wchar_t WCHAR;

and

typedef WCHAR TCHAR, *PTCHAR;

but there was comment in one of my posts that there is some difference between them. Then what is the difference?

like image 266
Mihran Hovsepyan Avatar asked Nov 17 '10 15:11

Mihran Hovsepyan


People also ask

What is Tchar and Wchar?

TCHAR is just a macro - if Unicode is defined as the character set for the project it maps. to wchar_t. So in that case there is no difference between them. if Unicode is NOT defined as the character set for the project it maps to char.

What does Wchar stand for?

This document sets out the walking, cycling and horse-riding assessment and review (WCHAR) process for highway schemes on motorways and all-purpose trunk roads.

Where is Tchar defined?

For Unicode platforms, TCHAR is defined as synonymous with the WCHAR type. MAPI clients can use the TCHAR data type to represent a string of either the WCHAR or char type. Be sure to define the symbolic constant UNICODE and limit the platform when it is required.

What is Tchar H?

tchar. h defines macros (which have the prefix _tcs ) that, with the correct preprocessor definitions, map to str , _mbs , or wcs functions, as appropriate. To build MBCS, define the symbol _MBCS . To build Unicode, define the symbol _UNICODE . To build a single-byte application, define neither (the default).


1 Answers

If you read the entire header, you will find:

#ifdef _UNICODE
typedef WCHAR TCHAR;
#else
typedef char TCHAR;
#endif

or words to that effect.

Perhaps MS has removed the narrow option of late.

like image 76
bmargulies Avatar answered Sep 28 '22 06:09

bmargulies