You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by John Lilley <jl...@datalever.com> on 2009/07/23 15:02:49 UTC

Building Xerces with XMLCH as unsigned short on Windows

Is there a way to make Xerces define XMLCh as unsigned short on Windows instead of wchar_t?  It may be a minor point, but we have a UTF-16 string type defined to use unsigned short, so it would also be nice to have Xerces using unsigned short to avoid casts.  Since it can use unsigned short on some platforms, why not Windows?

I'd like to use wchar_t, but we need to be able to overload UTF-32 vs UTF-16 string types and to do that, we need a 32-bit and 16-bit unsigned int type that is the same on all platforms.

On a different topic, will Xerces use unsigned short on all platforms for which sizeof(wchar_t) != 2?

Thanks
john lilley

Re: Building Xerces with XMLCH as unsigned short on Windows

Posted by Alberto Massari <am...@datadirect.com>.
Hi John,
the Windows build automatically selects wchar_t as XMLCh if you set the 
/Zc:wchar_t option (i.e. "treat wchar_t as a native type") as this will 
allow invoking Windows API using XMLCh arrays as strings. So, unsetting 
that option will automatically fallback to unsigned short.
If you want to force this option, just edit the 
util/Xerces_autoconf_config.msvc.hpp and recompile.

On other platforms Xerces will never use wchar_t (even if it is 16 bit) 
but will choose uint16_t or unsigned int or unsigned short depending on 
which type is 16 bit on that platform.

Alberto

John Lilley wrote:
> Is there a way to make Xerces define XMLCh as unsigned short on Windows instead of wchar_t?  It may be a minor point, but we have a UTF-16 string type defined to use unsigned short, so it would also be nice to have Xerces using unsigned short to avoid casts.  Since it can use unsigned short on some platforms, why not Windows?
>
> I'd like to use wchar_t, but we need to be able to overload UTF-32 vs UTF-16 string types and to do that, we need a 32-bit and 16-bit unsigned int type that is the same on all platforms.
>
> On a different topic, will Xerces use unsigned short on all platforms for which sizeof(wchar_t) != 2?
>
> Thanks
> john lilley
>
>