From 55011d4bfd46c920580d1aa6663bcfdb1e996d3e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 18 Apr 2017 14:11:15 -0700 Subject: Use a different way to get the size of structs with flexible array members --- OpenAL32/Include/alMain.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenAL32/Include/alMain.h') 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 -- cgit v1.2.3