[HarfBuzz] Conflict type declaration with Win32/64 API (SHORT, USHORT, ...)

Petr Kobalíček kobalicek.petr at gmail.com
Thu Jan 5 08:43:45 PST 2012


Hello list,

I'm trying to compile harfbuzz using MSVS2010. I just added important
files into the project and added bridge between Fog-Framework and
harfbuzz. But I encountered a problem that harfbuzz defines types
which conflicts with types which are part of Win32/64 API.

The error starts here:

#define USHORT	HB_USHORT
#define SHORT	HB_SHORT
#define ULONG	HB_ULONG
#define LONG	HB_LONG

typedef IntType<uint16_t> USHORT;	/* 16-bit unsigned integer. */
typedef IntType<int16_t>  SHORT;	/* 16-bit signed integer. */
typedef IntType<uint32_t> ULONG;	/* 32-bit unsigned integer. */
typedef IntType<int32_t>  LONG;		/* 32-bit signed integer. */

The error list is long, but the first messages are the most important:

2>C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\windef.h(48): error C2371: 'HB_ULONG' :
redefinition; different basic types
2>          c:\my\devel\cpp\fog\src\3rdparty\harfbuzz\hb-open-type-private.hh(392)
: see declaration of 'HB_ULONG'
2>C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\windef.h(50): error C2371: 'HB_USHORT' :
redefinition; different basic types
2>          c:\my\devel\cpp\fog\src\3rdparty\harfbuzz\hb-open-type-private.hh(390)
: see declaration of 'HB_USHORT'
2>C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\winnt.h(332): error C2371: 'HB_SHORT' :
redefinition; different basic types
2>          c:\my\devel\cpp\fog\src\3rdparty\harfbuzz\hb-open-type-private.hh(391)
: see declaration of 'HB_SHORT'
2>C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\winnt.h(333): error C2371: 'HB_LONG' :
redefinition; different basic types
2>          c:\my\devel\cpp\fog\src\3rdparty\harfbuzz\hb-open-type-private.hh(393)
: see declaration of 'HB_LONG'
2>C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\winnt.h(2235): error C2440: 'type cast' :
cannot convert from 'LONG_PTR' to 'HB_LONG'
2>          No constructor could take the source type, or constructor
overload resolution was ambiguous
2>C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\winnt.h(2235): error C2086: 'char
__C_ASSERT__[1]' : redefinition
2>          C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\winnt.h(2234) : see declaration of
'__C_ASSERT__'
2>C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\winnt.h(2458): warning C4190:
'_InterlockedIncrement16' has C-linkage specified, but returns UDT
'IntType<Type>' which is incompatible with C
2>          with

...

I know that these types like SHORT/USHORT, ... are defined inside the
ttf fonts and are in specification, but it's really hard to make sure
there is no conflict with Win32. So I'd like to ask whether it's
possible to accept a patch which will rename all harfbuzz types like
these to HB_SHORT, HB_USHORT, ..., so it will be guaranteed no type
conflict in the future. I haven't the patch right now, because I'd
like to ask here to find the best possible solution.

Another solution can be to maintain my private version of patched
harfbuzz, but personally I don't like this idea.

There are also many warnings related to implicit size_t -> int casts
(64-bit mode), but these are simple to fix.

Best regards
Petr Kobalicek



More information about the HarfBuzz mailing list