Win32: Fix symbol redefinition warnings

When both GLFW_INCLUDE_VULKAN and VK_USE_PLATFORM_WIN32_KHR were
defined, the GLFW header would define replacement versions of APIENTRY
and WINGDIAPI /before/ including the Vulkan header, which would include
windows.h, which (justifiably) defines APIENTRY and WINGDIAPI blindly.

Fixes #1524.

(cherry picked from commit 773f4495f0)
This commit is contained in:
Camilla Löwy 2019-07-12 14:23:12 +02:00
parent 95e7ad7e5b
commit 248e827673
2 changed files with 21 additions and 15 deletions

View File

@ -120,6 +120,8 @@ information on what to include when reporting a bug.
- Bugfix: The CMake config-file package used an absolute path and was not
relocatable (#1470)
- [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
symbol redefinition (#1524)
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
(#1462,#1528)

View File

@ -96,6 +96,25 @@ extern "C" {
#define _WIN32
#endif /* _WIN32 */
/* Include because most Windows GLU headers need wchar_t and
* the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
* Include it unconditionally to avoid surprising side-effects.
*/
#include <stddef.h>
/* Include because it is needed by Vulkan and related functions.
* Include it unconditionally to avoid surprising side-effects.
*/
#include <stdint.h>
#if defined(GLFW_INCLUDE_VULKAN)
#include <vulkan/vulkan.h>
#endif /* Vulkan header */
/* The Vulkan header may have indirectly included windows.h (because of
* VK_USE_PLATFORM_WIN32_KHR) so we offer our replacement symbols after it.
*/
/* It is customary to use APIENTRY for OpenGL function pointer declarations on
* all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
*/
@ -122,17 +141,6 @@ extern "C" {
#define GLFW_CALLBACK_DEFINED
#endif /* CALLBACK */
/* Include because most Windows GLU headers need wchar_t and
* the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
* Include it unconditionally to avoid surprising side-effects.
*/
#include <stddef.h>
/* Include because it is needed by Vulkan and related functions.
* Include it unconditionally to avoid surprising side-effects.
*/
#include <stdint.h>
/* Include the chosen OpenGL or OpenGL ES headers.
*/
#if defined(GLFW_INCLUDE_ES1)
@ -211,10 +219,6 @@ extern "C" {
#endif /* OpenGL and OpenGL ES headers */
#if defined(GLFW_INCLUDE_VULKAN)
#include <vulkan/vulkan.h>
#endif /* Vulkan header */
#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
/* GLFW_DLL must be defined by applications that are linking against the DLL
* version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW