sudhanshu22

Hi all,
I want to know what is the difference between TCHAR and char e.g.
char ch;
TCHAR ch;
whar is the difference between the two above.

Another,
There is a data type named CSTRING defined as
typedef ATL::CStringT< TCHAR, StrTraitMFC< TCHAR > > CString;
The above is defined in afxstr.h.
Can anybody tell me the description of the above

Regards,
Sudhanshu


Re: Visual C++ Language Differences between microsoft data types and legacy data types

einaros

sudhanshu22 wrote:
Hi all,
I want to know what is the difference between TCHAR and char e.g.
char ch;
TCHAR ch;
whar is the difference between the two above.


TCHAR is a generic type (defined by a set of preprocessor directives), which resolves to char if you're compiling for MULTIBYTE, and wchar_t if you're compiling for UNICODE.

sudhanshu22 wrote:

Another,
There is a data type named CSTRING defined as
typedef ATL::CStringT< TCHAR, StrTraitMFC< TCHAR > > CString;
The above is defined in afxstr.h.
Can anybody tell me the description of the above


That line specializes CString depending on which character set you're using. Since it depends on TCHAR, which behaves differently for unicode and multibyte, CString will have different traits. TCHAR is, as mentioned, defined through a set of preprocessor directives; whereas CString is a typedef involving the CStringT template.





Re: Visual C++ Language Differences between microsoft data types and legacy data types

sudhanshu22

Thanks Einaros,
Unfortunately I don't know what is the difference between UNICODE and multibyte. Also, in a souce code, can I find that preprocessor directive that make this difference ( UNICODE or multibyte).




Re: Visual C++ Language Differences between microsoft data types and legacy data types

einaros

sudhanshu22 wrote:
Thanks Einaros,
Unfortunately I don't know what is the difference between UNICODE and multibyte. Also, in a souce code, can I find that preprocessor directive that make this difference ( UNICODE or multibyte).


http://en.wikipedia.org/wiki/Unicode

Open tchar.h, and you'll see a few #ifdef _UNICODE blocks.