]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
configure: Check if C99 "static" keyword is supported for array sizes.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 30 Jun 2016 17:24:34 +0000 (20:24 +0300)
committerGitLab <gitlab@git.dovecot.net>
Thu, 30 Jun 2016 22:02:00 +0000 (01:02 +0300)
configure.ac
m4/static_array.m4 [new file with mode: 0644]
src/lib/macros.h

index ef8312cc5d1cf2cc598a2e4d6b84917294b060e7..f7de2ffaf46d67e2344f0cc998a0590c9301a5f1 100644 (file)
@@ -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 (file)
index 0000000..fb6a6ca
--- /dev/null
@@ -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])
+])
index 84452073749ce027d49162d7d893582cd4dae85f..ba5fbe55005d16b1e4aad364ce134bd0befef216 100644 (file)
 #endif
 
 #ifdef __cplusplus
-#  define STATIC_ARRAY
-#else
-#  define STATIC_ARRAY static
+#  undef STATIC_ARRAY
 #endif
 
 #endif