_UNICODE vs UNICODE

Francois Gouget fgouget at free.fr
Mon Jan 21 13:51:39 CST 2002


On Mon, 21 Jan 2002, Andriy Palamarchuk wrote:

> Francois Gouget wrote:
> > On Fri, 18 Jan 2002, Andriy Palamarchuk wrote:
> > > Using macro name "UNICODE" instead of "_UNICODE"
> is a
> > > typo, right?
> >
> >   No, not necessarily. Windows has both and
> dinput.h,
> > for instance,
> > uses UNICODE, not _UNICODE.
> >
> >   But I have no idea why they have two.
>
> I did a little research and found in a few places
> information that UNICODE is used by Windows headers,
> _UNICODE is used by C-runtime/MFC headers. However I
> did not find official explanation of this.
> Some examples, including a few MSDN ones, define both.
> E.g. see:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_exch2k_getting_the_host_domain_name.asp
>
> Can you tell now where we need to use which one?

   All Windows headers use UNICODE except the following which also
make references to _UNICODE:

 * msacm.h
   This one does something like:
      #if defined(UNICODE) && !defined(_UNICODE)
      #define _UNICODE
      #endif

 * edk.h
   This one defines _UNICODE if UNICODE is defined, but then it will
   only test UNICODE!

 * oledlg.h
   This one will make sure that if one of UNICODE or _UNICODE is
   defined, then the other one is defined too.

 * bdnapi.h, dbdao.h, tchar.h
   These only test _UNICODE

 * sqlole.h
   This one tests both and defines SQLOLE_UNICODE to simplify further
   tests.


   It's a big mess if you ask me. The reason why there is no official
explanation is that there was simply no design. But currently our
headers all do the right thing (tchar.h uses _UNICODE and msacm.h uses
neither for now).


   The Petzold mentions that you need _UNICODE for tchar.h and UNICODE
for the other headers but does not go into why this was done this way.
All it says is to define both if you are writing a Unicode application.


--
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
                         "Utilisateur" (nom commun) :
        Mot utilisé par les informaticiens en lieu et place d'"idiot".





More information about the wine-devel mailing list