2-byte (UCS-2) wide strings under GCC

Posted by Seva Alekseyev on Stack Overflow See other posts from Stack Overflow or by Seva Alekseyev
Published on 2010-05-07T17:28:34Z Indexed on 2010/05/08 1:08 UTC
Read the original article Hit count: 275

Filed under:
|
|
|
|

Hi all,

when porting my Visual C++ project to GCC, I found out that the wchar_t datatype is 4-byte UTF-32 by default. I could override that with a compiler option, but then the whole wcs* (wcslen, wcscmp, etc.) part of RTL is rendered unusable, since it assumes 4-byte wide strings.

For now, I've reimplemented 5-6 of these functions from scratch and #defined my implementations in. But is there a more elegant option - say, a build of GCC RTL with 2-byte wchar-t quietly sitting somewhere, waiting to be linked?

The specific flavors of GCC I'm after are Xcode on Mac OS X, Cygwin, and the one that comes with Debian Linux Etch.

© Stack Overflow or respective owner

Related posts about gcc

Related posts about c++