Wednesday, July 21, 2010

Unicode CORBA-applications with ACE+TAO

Below is a bit of library's documentation about wchar support:

"There are three different wchar configurations that ACE can use. These are no support mode, regular support mode, and full support mode.
By default, ACE will not use wchar_t at all. This is for platforms where wchar_t does not exist or support for it is pretty flakey.
If ACE_HAS_WCHAR is defined, then ACE classes will be expanded to have extra methods which take in wchar_t strings. Note that all the methods available with No Support are also available here.
Full support is turned on if ACE_HAS_WCHAR and ACE_USES_WCHAR are defined. Like Regular Support, both char and wchar_t versions of some methods are available, but unlike Regular Support, other methods that have char arguments or return values may have wchar_t arguments or return values."

What does it mean?
If you need to use wide strings in interface, you must build ACE with ACE_HAS_WCHAR macros defined. For example, you have something like this in your IDL:

To use wstring in IDL you must build ACE with ACE_HAS_WCHAR. To do it, edit file ACE_wrapper/ace/config.h. If it is not exists - create it and put in it the following line:

#define ACE_HAS_WCHAR

In Visual Studio you can define _UNICODE macro or just change character set to Unicode in project settings of your application. But in this case you can't link with TAO. If you want to use _Unicode macro, ACE and TAO must be rebuild with both ACE_HAS_WCHAR and ACE_USES_WCHAR macroses defined in config.h.
Previous versions of the TAO (e.g. TAO 1.5 from may, 2006) has a bug with using ACE_USES_WCHAR, so you may need to download latest ACE+TAO package to successfully build.