Hi,

I have unicode C application. I am using the following macro to define my 
string 
to 2 byte width characters.

#ifdef UNICODE
#define _T(x) L##x

But I see that GCC compiler maps 'L' to wchar_t, which is 4 byte on Linux. I 
have used -fshort-wchar option
on Linux but I want my application to be portable on AIX as well, which does 
not 
have this option. I am not able
to findbest way to define _T(x) of UNICODE version, which takes 2 byte wide 
character always.

I got the following explanation about wchar_t from The Unicode Standard, 
Version 
4.0, issued by the Unicode
Consortiumand published by Addison-Wesley.

"The width of wchar_t is compiler-specific and can be as small as 8 bits. 
Consequently,
programs that need to be portable across any C or C++ compiler should not use 
wchar_t
for storing Unicode text. The wchar_t type is intended for storing 
compiler-defined wide
characters, which may be Unicode characters in some compilers. However, 
programmers
who want a UTF-16 implementation can use a macro or typedef (for example, 
UNICHAR)
that can be compiled as unsigned short or wchar_t depending on the target 
compiler
and platform."

Taking this, what is the best way to define _T(x) macro of UNICODE version, so 
that my strings will always be
2 byte wide character?

Thanks in Advance.
Sowmya.

Reply via email to