[gtk/fix.ngl.msvc] gskngltexturelibraryprivate.h: Fix build on Visual Studio
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix.ngl.msvc] gskngltexturelibraryprivate.h: Fix build on Visual Studio
- Date: Tue, 2 Mar 2021 06:52:53 +0000 (UTC)
commit 2b6ce3af0fdc985c9f09148a6553d0b2ce457f8e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Mar 2 14:44:29 2021 +0800
gskngltexturelibraryprivate.h: Fix build on Visual Studio
The 'GskNglTextureAtlasEntry' structure is used as a member in two other
structures in two Gsk private headers, namely 'GskNglGlyphValue' and
'GskNglIconData', but the build breaks on Visual Studio since
'GskNglTextureAtlasEntry' contains a last member that is a zero-sized array
that is normally OK if it is the last member of structure -or- if the structure
that contains a 'GskNglTextureAtlasEntry' structure as its last member.
Otherwise, a GCCism is involved here.
Fix the build on Visual Studio compilers by not using a zero-sized array as
a last member of 'GskNglTextureAtlasEntry', on Visual Studio compilers.
gsk/ngl/gskngltexturelibraryprivate.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/gsk/ngl/gskngltexturelibraryprivate.h b/gsk/ngl/gskngltexturelibraryprivate.h
index 56c3d604cc..874eeb769b 100644
--- a/gsk/ngl/gskngltexturelibraryprivate.h
+++ b/gsk/ngl/gskngltexturelibraryprivate.h
@@ -53,6 +53,12 @@ typedef struct _GskNglTextureAtlas
void *user_data;
} GskNglTextureAtlas;
+#if defined (_MSC_VER) && !defined (__clang__)
+# define NGL_TRAILING_DATA_SIZE 1
+#else
+# define NGL_TRAILING_DATA_SIZE 0
+#endif
+
typedef struct _GskNglTextureAtlasEntry
{
/* A backreference to either the atlas or texture containing
@@ -89,9 +95,11 @@ typedef struct _GskNglTextureAtlasEntry
/* Suffix data that is per-library specific. gpointer used to
* guarantee the alignment for the entries using this.
*/
- gpointer data[0];
+ gpointer data[NGL_TRAILING_DATA_SIZE];
} GskNglTextureAtlasEntry;
+#undef NGL_TRAILING_DATA_SIZE
+
typedef struct _GskNglTextureLibrary
{
GObject parent_instance;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]