[Freeciv-Dev] (PR#12007) c99.m4 improvements
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12007 >
This patch:
- Adds a check for c99 initializers (this is needed since we actually do
use them; see PR#11794).
- Renames c99 checks to be non-freeciv-specific (which is good since
c99.m4 is rather reusable) and to include C99 in the name.
- Improves documentation in c99.m4.
-jason
? foo.c
Index: configure.ac
===================================================================
RCS file: /home/freeciv/CVS/freeciv/configure.ac,v
retrieving revision 1.91
diff -u -r1.91 configure.ac
--- configure.ac 20 Jan 2005 00:00:12 -0000 1.91
+++ configure.ac 25 Jan 2005 02:50:29 -0000
@@ -275,8 +275,9 @@
fi
FC_DEBUG
-FC_VARIADIC_MACROS
-FC_VARIABLE_ARRAYS
+AC_C99_VARIADIC_MACROS
+AC_C99_VARIABLE_ARRAYS
+AC_C99_INITIALIZERS
if test "$CVS_DEPS" = "maybe"; then
dnl Should also check for gmake?
Index: m4/c99.m4
===================================================================
RCS file: /home/freeciv/CVS/freeciv/m4/c99.m4,v
retrieving revision 1.4
diff -u -r1.4 c99.m4
--- m4/c99.m4 31 Jan 2004 17:49:52 -0000 1.4
+++ m4/c99.m4 25 Jan 2005 02:50:30 -0000
@@ -1,10 +1,12 @@
-# Check for the presense of C99 features. These may be optional or required.
+# Check for the presence of C99 features. Generally the check will fail
+# if the feature isn't present (a C99 compiler isn't that much to ask,
+# right?).
# Check C99-style variadic macros (required):
#
# #define PRINTF(msg, ...) (printf(msg, __VA_ARGS__)
#
-AC_DEFUN([FC_VARIADIC_MACROS],
+AC_DEFUN([AC_C99_VARIADIC_MACROS],
[
dnl Check for variadic macros
AC_CACHE_CHECK([for C99 variadic macros],
@@ -27,7 +29,7 @@
#
# char concat_str[strlen(s1) + strlen(s2) + 1];
#
-AC_DEFUN([FC_VARIABLE_ARRAYS],
+AC_DEFUN([AC_C99_VARIABLE_ARRAYS],
[
dnl Check for variable arrays
AC_CACHE_CHECK([for C99 variable arrays],
@@ -43,3 +45,33 @@
AC_MSG_ERROR([A compiler supporting C99 variable arrays is required])
fi
])
+
+# Check C99-style initializers (required):
+#
+# struct timeval tv = {.tv_sec = 0, .tv_usec = 500000};
+# int fibonacci[6] = {[0] = 0, [1] = 1, [2] = 1, [3] = 2, [4] = 3, [5] = 5};
+#
+AC_DEFUN([AC_C99_INITIALIZERS],
+[
+ dnl Check for C99 initializers
+ AC_CACHE_CHECK([for C99 initializers],
+ [ac_cv_c99_initializers],
+ [AC_TRY_COMPILE(
+ [struct foo {
+ int an_integer;
+ char *a_string;
+ int an_array[5];
+ union {int x, y;} a_union;
+ };
+ ],
+ [struct foo bar = {.an_array = {0, [3] = 2, [2] = 1, [4] = 3},
+ .an_integer = 999,
+ .an_array[1] = 1,
+ .a_string = "does it work?",
+ .a_union = {.y = 243}};],
+ [ac_cv_c99_initializers=yes],
+ [ac_cv_c99_initializers=no])])
+ if test "${ac_cv_c99_initializers}" != "yes"; then
+ AC_MSG_ERROR([A compiler supporting C99 initializers is required])
+ fi
+])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12007) c99.m4 improvements,
Jason Short <=
|
|