瀏覽代碼

Fix APIENTRY from windows.h being undefined

Some extension loader headers include windows.h.  If they were included
before glfw3.h, glfw3native.h would leave APIENTRY undefined.  This adds
the GLFW_APIENTRY_DEFINED macro to signal when GLFW "owns" APIENTRY and
may undefine it.

Fixes #1062.
Camilla Löwy 8 年之前
父節點
當前提交
c23fca6343
共有 3 個文件被更改,包括 6 次插入1 次删除
  1. 1 0
      README.md
  2. 1 0
      include/GLFW/glfw3.h
  3. 4 1
      include/GLFW/glfw3native.h

+ 1 - 0
README.md

@@ -190,6 +190,7 @@ information on what to include when reporting a bug.
 - [Win32] Bugfix: Monitor events were not emitted (#784)
 - [Win32] Bugfix: The Cygwin DLL was installed to the wrong directory (#1035)
 - [Win32] Bugfix: Normalization of axis data via XInput was incorrect (#1045)
+- [Win32] Bugfix: `glfw3native.h` would undefine a foreign `APIENTRY` (#1062)
 - [X11] Moved to XI2 `XI_RawMotion` for disable cursor mode motion input (#125)
 - [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
 - [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X

+ 1 - 0
include/GLFW/glfw3.h

@@ -105,6 +105,7 @@ extern "C" {
  #else
   #define APIENTRY
  #endif
+ #define GLFW_APIENTRY_DEFINED
 #endif /* APIENTRY */
 
 /* Some Windows OpenGL headers need this.

+ 4 - 1
include/GLFW/glfw3native.h

@@ -86,7 +86,10 @@ extern "C" {
  // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
  // example to allow applications to correctly declare a GL_ARB_debug_output
  // callback) but windows.h assumes no one will define APIENTRY before it does
- #undef APIENTRY
+ #if defined(GLFW_APIENTRY_DEFINED)
+  #undef APIENTRY
+  #undef GLFW_APIENTRY_DEFINED
+ #endif
  #include <windows.h>
 #elif defined(GLFW_EXPOSE_NATIVE_COCOA)
  #include <ApplicationServices/ApplicationServices.h>