From: Timo Sirainen Date: Thu, 30 Jun 2016 17:24:34 +0000 (+0300) Subject: configure: Check if C99 "static" keyword is supported for array sizes. X-Git-Tag: 2.3.0.rc1~3359 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc3586bca89b79dfccdd3c155d80d5082aabc07b;p=thirdparty%2Fdovecot%2Fcore.git configure: Check if C99 "static" keyword is supported for array sizes. --- diff --git a/configure.ac b/configure.ac index ef8312cc5d..f7de2ffaf4 100644 --- a/configure.ac +++ b/configure.ac @@ -470,6 +470,7 @@ DOVECOT_TM_GMTOFF DOVECOT_GMTIME_MAX DOVECOT_TIME_T_SIGNED +DOVECOT_C_STATIC_ARRAY DOVECOT_C_FLEXIBLE_ARRAY_MEMBER DOVECOT_IOVEC diff --git a/m4/static_array.m4 b/m4/static_array.m4 new file mode 100644 index 0000000000..fb6a6ca55f --- /dev/null +++ b/m4/static_array.m4 @@ -0,0 +1,19 @@ +AC_DEFUN([DOVECOT_C_STATIC_ARRAY], [ + AC_CACHE_CHECK([if we can use C99 static in array sizes],i_cv_c99_static_arrays,[ + AC_TRY_COMPILE([ + void foo(int arr[static 20]); + ], [ + ], [ + i_cv_c99_static_arrays=yes + ], [ + i_cv_c99_static_arrays=no + ]) + ]) + + if test $i_cv_c99_static_arrays = yes; then + static_value=static + else + static_value= + fi + AC_DEFINE_UNQUOTED(STATIC_ARRAY, $static_value, [C99 static array]) +]) diff --git a/src/lib/macros.h b/src/lib/macros.h index 8445207374..ba5fbe5500 100644 --- a/src/lib/macros.h +++ b/src/lib/macros.h @@ -227,9 +227,7 @@ #endif #ifdef __cplusplus -# define STATIC_ARRAY -#else -# define STATIC_ARRAY static +# undef STATIC_ARRAY #endif #endif