From 2be8fd3eb3d412355ccca51ac840cb869d5d5f8c Mon Sep 17 00:00:00 2001 From: Ben Campbell Date: Tue, 1 May 2018 12:59:26 +1200 Subject: [PATCH] Fixes to compile on windows with msys2 msys2 seems to be unsure of it's IDWriteTypography definition and disables it by default. This overrides the disabling (The IDWriteTypography definition looks OK to me, and seems to work fine). This commit also adds in a canary to detect compilers that have a non-16bit wchar_t on windows (eg a gcc focused on porting unix code rather than compiling windows code). --- windows/utf16.cpp | 7 +++++++ windows/winapi.hpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/windows/utf16.cpp b/windows/utf16.cpp index 131759e9..143bad24 100644 --- a/windows/utf16.cpp +++ b/windows/utf16.cpp @@ -1,6 +1,13 @@ // 21 april 2016 #include "uipriv_windows.hpp" +// sanity check - make sure wchar_t is 16 bits (the assumption on windows) +// (MinGW-w64 gcc does seem to define a 16bit wchar_t, but you never know. Other windows gcc ports might not) +#if WCHAR_MAX > 0xFFFF + #error wchar_t larger than 16bit +#endif + + // see http://stackoverflow.com/a/29556509/3408572 WCHAR *toUTF16(const char *str) diff --git a/windows/winapi.hpp b/windows/winapi.hpp index 1b2ab000..909aa56b 100644 --- a/windows/winapi.hpp +++ b/windows/winapi.hpp @@ -23,6 +23,13 @@ #define _WIN32_IE 0x0700 #define NTDDI_VERSION 0x06000000 +// the msys2 header has an unverified IDWriteTypography definition. +// Would be good to get it verified and fixed in msys2, but in the meantime, +// this define lets us compile.... +#if !defined(_MSC_VER) +#define __MINGW_USE_BROKEN_INTERFACE +#endif + #include // Microsoft's resource compiler will segfault if we feed it headers it was not designed to handle