dwrite: Avoid redefining the DWRITE_GLYPH_RUN typedef.
Francois Gouget
fgouget at free.fr
Fri Oct 10 01:37:07 CDT 2014
Doing so breaks compilation on non-C11 compilers.
---
Based on a patch by Henri Verbeet.
Note that the PSDK does not define any typedef in dwrite.h, yet does as
if they were present. That seems to be a C++-only feature. This means we
do have to define these typedefs so we can use the right prototypes in
C.
Also the DWRITE_GLYPH_RUN typedef is the only one being defined in
another header which is lucky otherwise we'd have to do a lot more of
this.
This patch fixes compilation on FreeBSD and presumably on any platform
that uses GCC < 4.6(*). Note that it's not just the old FreeBSD 7.0 and
8.1. FreeBSD 10's brand new Clang compiler also complained about this
but only as a warning (and there's a compiler option to disable that
warning).
(*) https://gcc.gnu.org/wiki/C11Status
However that page seems to imply that anonymous structs and unions
are not supported in GCC < 4.6 which is wrong.
include/d2d1.idl | 3 +++
include/dwrite.idl | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/d2d1.idl b/include/d2d1.idl
index 4934acc..1623e46 100644
--- a/include/d2d1.idl
+++ b/include/d2d1.idl
@@ -37,7 +37,10 @@ interface IDWriteTextLayout;
interface IWICBitmapSource;
interface IWICBitmap;
+cpp_quote("#ifndef __dwrite_h__")
+/* already defined in dwrite.h but needed for WIDL */
typedef struct DWRITE_GLYPH_RUN DWRITE_GLYPH_RUN;
+cpp_quote("#endif /* __dwrite_h__ */")
typedef D2D_POINT_2F D2D1_POINT_2F;
typedef D2D_MATRIX_3X2_F D2D1_MATRIX_3X2_F;
diff --git a/include/dwrite.idl b/include/dwrite.idl
index 1888215..2ae5164 100644
--- a/include/dwrite.idl
+++ b/include/dwrite.idl
@@ -382,7 +382,11 @@ typedef struct DWRITE_TRIMMING
UINT32 delimiterCount;
} DWRITE_TRIMMING;
-typedef struct DWRITE_GLYPH_RUN
+cpp_quote("#ifndef __d2d1_h__")
+typedef struct DWRITE_GLYPH_RUN DWRITE_GLYPH_RUN;
+cpp_quote("#endif /* __d2d1_h__ */")
+
+struct DWRITE_GLYPH_RUN
{
IDWriteFontFace* fontFace;
FLOAT fontEmSize;
@@ -392,7 +396,7 @@ typedef struct DWRITE_GLYPH_RUN
DWRITE_GLYPH_OFFSET const* glyphOffsets;
BOOL isSideways;
UINT32 bidiLevel;
-} DWRITE_GLYPH_RUN;
+};
typedef struct DWRITE_GLYPH_RUN_DESCRIPTION
{
--
2.1.1
More information about the wine-patches
mailing list