[HarfBuzz] Windows build with MSVC 2008

Behdad Esfahbod behdad at behdad.org
Wed Aug 3 17:46:19 PDT 2011

Hi Sebastien,

On 08/03/11 20:39, Sebastien Metrot wrote:
> Hi All,
> I have added harfbuzz-ng to my GUI framework and it now works fine on OSX and iOS. While compiling the code on windows, I had to make some changes to get harfbuzz to build and run:
> - USHORT, SHORT, ULONG and LONG are already defined by the Win32 SDK so I had to #define them in hb-opentype-private.hh:

What a weird coincidence!  I just did that yesterday.  Try with master.

> #define SHORT HB_SHORT
> #define ULONG HB_ULONG
> #define LONG HB_LONG

> - I also had to disable the extern "C" { } declarations, all code now being in .cc files and some functions returning class object, the compiler refuses them. So I changed line 32 of hb_common.h to: # if (defined __cplusplus) && (!defined WIN32)

Well, we need those in the public .h files at least.  I'll give it a look
again.  There was some weird reason I added them to .cc files.

Which functions return class objects BTW?

> - Last but not least, I noticed what looks like a bug to me: the declaration of the hb_prealloced_array_t template lacks a constructor, so all its data is rubbish if the compiler doesn't blank it or if the memory is not already zeroed, which is the case with visual C++.

Interesting.  I'll take a look.  Can you clarify: is the static global
instances you are talking about or any other ones?  I assumed global ones get
zeroed like POD structs in C are.

> With all these changes I have been able to build harfbuzz and two of my test programs. The bad news is that the first program runs but displays mismatched glyphs (and that's for Latin1 text with the Vera Sans mono font, so I guess it should be pretty simple). The second program seems stuck in a loop in the method hb_ot_map_builder_t::compile(...) with the font Andalus and some arabian text.

That's not what I expect...

I have got to build DLLs using mingw32.  I can send you one if you find it
useful.  Regardless, we need to figure out what's wrong with your compilation.
 Did you try attaching a debugger to the infinite loop?


> I welcome any help finding solutions :-).

More information about the HarfBuzz mailing list