diff --git a/configure.ac b/configure.ac index 754fd47e4..12045cf18 100644 --- a/configure.ac +++ b/configure.ac @@ -11,6 +11,8 @@ AC_PROG_LIBTOOL dnl ([1.4]) Don't remove! AC_PROG_CC AC_PROG_CXX +AC_C_FLEXIBLE_ARRAY_MEMBER + AC_CHECK_FUNCS(mprotect sysconf getpagesize) AC_CHECK_HEADERS(unistd.h sys/mman.h) diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index f8cbe7810..ad8f241c0 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -35,8 +35,8 @@ typedef SHORT Value; -typedef Value ValueRecord[VAR]; -ASSERT_SIZE_VAR (Value, 0, ValueRecord); +typedef Value ValueRecord[VAR0]; +ASSERT_SIZE_VAR (ValueRecord, 0, Value); struct ValueFormat : USHORT { diff --git a/src/hb-private.h b/src/hb-private.h index 845d1f04d..d86c0c2c2 100644 --- a/src/hb-private.h +++ b/src/hb-private.h @@ -148,11 +148,18 @@ typedef int hb_mutex_t; #define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size)) -#define VAR 1 /* Size signifying variable-sized array */ +/* Size signifying variable-sized array */ +#ifdef FLEXIBLE_ARRAY_MEMBER +#define VAR FLEXIBLE_ARRAY_MEMBER +#else +#define VAR 1 +#endif + +#define VAR0 (VAR+0) #define ASSERT_SIZE_VAR(_type, _size, _var_type) \ - ASSERT_STATIC (sizeof (_type) == (_size) + VAR * sizeof (_var_type)) + ASSERT_STATIC (sizeof (_type) == (_size) + VAR0 * sizeof (_var_type)) #define ASSERT_SIZE_VAR2(_type, _size, _var_type1, _var_type2) \ - ASSERT_STATIC (sizeof (_type) == (_size) + VAR * sizeof (_var_type1) + VAR * sizeof (_var_type2)) + ASSERT_STATIC (sizeof (_type) == (_size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)) #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) #define _HB_BOOLEAN_EXPR(expr) \