UNICODE version of _T(x) macro

From: sowmya satyanarayana (sowmya_satyanarayana@yahoo.com)
Date: Mon Nov 22 2010 - 02:14:20 CST

  • Next message: Doug Ewell: "RE: UNICODE version of _T(x) macro"

    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.

    This archive was generated by hypermail 2.1.5 : Mon Nov 22 2010 - 11:04:02 CST