aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-04-18 14:11:15 -0700
committerChris Robinson <[email protected]>2017-04-18 14:11:15 -0700
commit55011d4bfd46c920580d1aa6663bcfdb1e996d3e (patch)
tree67040a4f7e98acedc060930e146854f61dd8e71b /OpenAL32/Include
parentde62ab97e912525f20272153f6a4c896e833839d (diff)
Use a different way to get the size of structs with flexible array members
Diffstat (limited to 'OpenAL32/Include')
-rw-r--r--OpenAL32/Include/alMain.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 191bb658..3a8aabde 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -225,6 +225,12 @@ typedef ALuint64SOFT ALuint64;
#define DECL_FORMAT(x, y, z)
#endif
+/* Calculates the size of a struct with N elements of a flexible array member.
+ * GCC and Clang allow offsetof(Type, fam[N]) for this, but MSVC seems to have
+ * trouble, so a bit more verbose workaround is needed.
+ */
+#define FAM_SIZE(T, M, N) (offsetof(T, M) + sizeof(((T*)NULL)->M[0])*(N))
+
#if defined(__GNUC__) && defined(__i386__)
/* force_align_arg_pointer is required for proper function arguments aligning
* when SSE code is used. Some systems (Windows, QNX) do not guarantee our