From 6770ae055666af6f8be1142075890d073b115f03 Mon Sep 17 00:00:00 2001
From: Camilla Berglund <elmindreda@elmindreda.org>
Date: Fri, 13 Sep 2013 12:22:28 +0200
Subject: [PATCH] Added workaround for legacy MinGW.

When building on legacy MinGW, WINVER and UNICODE need to be defined
before the inclusion of stddef.h (by glfw3.h), which is itself included
before win32_platform.h.
---
 CMakeLists.txt | 7 +++++++
 README.md      | 1 +
 2 files changed, 8 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 829a6436..b2a61ab1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -163,6 +163,13 @@ if (_GLFW_WIN32)
     if (GLFW_USE_OPTIMUS_HPG)
         set(_GLFW_USE_OPTIMUS_HPG 1)
     endif()
+
+    # HACK: When building on MinGW, WINVER and UNICODE need to be defined before
+    # the inclusion of stddef.h (by glfw3.h), which is itself included before
+    # win32_platform.h.  We define them here until a saner solution can be found
+    # NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
+    add_definitions(-DUNICODE)
+    add_definitions(-DWINVER=0x0501)
 endif()
 
 #--------------------------------------------------------------------
diff --git a/README.md b/README.md
index f24de6a1..511f73a5 100644
--- a/README.md
+++ b/README.md
@@ -205,6 +205,7 @@ See the [GLFW documentation](http://www.glfw.org/docs/latest/).
 ## Changelog
 
  - [Win32] Bugfix: `_WIN32_WINNT` was not set to Windows XP or later
+ - [Win32] Bugfix: Legacy MinGW needs `WINVER` and `UNICODE` before `stddef.h`
  - [X11] Bugfix: Events for mouse buttons 4 and above were not reported