Skip to content

Commit

Permalink
[win] Consolidate windows.h include tips and tricks
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Jul 19, 2014
1 parent f26d59d commit db30828
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 0 additions & 4 deletions src/hb-atomic-private.hh
Expand Up @@ -44,10 +44,6 @@

#elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__))

#define WIN32_LEAN_AND_MEAN
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#endif
#include <windows.h>

/* MinGW has a convoluted history of supporting MemoryBarrier
Expand Down
1 change: 0 additions & 1 deletion src/hb-mutex-private.hh
Expand Up @@ -44,7 +44,6 @@

#elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__))

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef CRITICAL_SECTION hb_mutex_impl_t;
#define HB_MUTEX_IMPL_INIT { NULL, 0, 0, NULL, NULL, 0 }
Expand Down
12 changes: 12 additions & 0 deletions src/hb-private.hh
Expand Up @@ -116,6 +116,18 @@
#define HB_FUNC __func__
#endif

#ifdef _WIN32
/* We need Windows Vista for both Uniscribe backend and for
* MemoryBarrier. We don't support compiling on Windows XP,
* though we run on it fine. */
# if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600
# undef _WIN32_WINNT
# endif
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0600
# endif
# define WIN32_LEAN_AND_MEAN
#endif


/* Basics */
Expand Down
3 changes: 0 additions & 3 deletions src/hb-uniscribe.cc
Expand Up @@ -24,9 +24,6 @@
* Google Author(s): Behdad Esfahbod
*/

#define _WIN32_WINNT 0x0600
#define WIN32_LEAN_AND_MEAN

#define HB_SHAPER uniscribe
#include "hb-shaper-impl-private.hh"

Expand Down
3 changes: 0 additions & 3 deletions src/hb-uniscribe.h
Expand Up @@ -29,9 +29,6 @@

#include "hb.h"

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#endif
#include <windows.h>

HB_BEGIN_DECLS
Expand Down

2 comments on commit db30828

@jfkthame
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke my build on Cygwin64, which appears to define __CYGWIN__ but not _WIN32; I end up with lots of undefined symbols in hb-uniscribe.cc (things that were dependent on setting _WIN32_WINNT).

To fix, I've done

diff --git a/src/hb-private.hh b/src/hb-private.hh
index 68223b3..82566c8 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -116,7 +116,7 @@
 #define HB_FUNC __func__
 #endif

-#ifdef _WIN32
+#if (defined(_WIN32) || defined(__CYGWIN__))
    /* We need Windows Vista for both Uniscribe backend and for
     * MemoryBarrier.  We don't support compiling on Windows XP,
     * though we run on it fine. */

which seems to make it happy again.

@behdad
Copy link
Member Author

@behdad behdad commented on db30828 Jul 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

Please sign in to comment.