[tor-commits] [tor/master] Require two c99 features (midblock decls, designated initializers)
nickm at torproject.org
nickm at torproject.org
Fri Sep 26 15:15:33 UTC 2014
commit 7f5103ec59e1e1da6c32e2bb0a3b1b6e437d57e4
Author: Nick Mathewson <nickm at torproject.org>
Date: Thu Sep 25 11:20:04 2014 -0400
Require two c99 features (midblock decls, designated initializers)
c99 lets us do neat stuff like:
{
int j, k;
foo(&j, &k);
int z = j + k;
}
and also
struct point { int x; int y; };
struct point pt = { .x=5, .y=5 };
This commit makes the configure scripts check to make sure your
compiler implements them. It also disables our longstanding warning
about midblock declarations.
Closes ticket 13233.
---
changes/require-c99 | 10 ++++++++++
configure.ac | 24 +++++++++++++++++++++++-
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/changes/require-c99 b/changes/require-c99
new file mode 100644
index 0000000..61d9612
--- /dev/null
+++ b/changes/require-c99
@@ -0,0 +1,10 @@
+ o New compiler requirements:
+ - Tor 0.2.6.x requires that your compiler support more of the C99
+ language standard than before. The 'configure' script now detects
+ whether your compiler supports C99 mid-block declarations and
+ designated initializers. If it does not, Tor will not compile.
+
+ We may revisit this requirement if it turns out that a significant
+ number of people need to build Tor with compilers that don't
+ bother implementing a 15-year-old standard. Closes ticket 13233.
+
diff --git a/configure.ac b/configure.ac
index 5aeeeb4..15154b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -221,6 +221,28 @@ AC_C_FLEXIBLE_ARRAY_MEMBER
fi
])
+AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
+ tor_cv_c_c99_decl,
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
+ [tor_cv_c_c99_decl=yes],
+ [tor_cv_c_c99_decl=no] )])
+if test "$tor_cv_c_c99_decl" != "yes"; then
+ AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
+fi
+
+AC_CACHE_CHECK([for working C99 designated initializers],
+ tor_cv_c_c99_designated_init,
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([struct s { int a; int b; };],
+ [[ struct s ss = { .b = 5, .a = 6 }; ]])],
+ [tor_cv_c_c99_designated_init=yes],
+ [tor_cv_c_c99_designated_init=no] )])
+
+if test "$tor_cv_c_c99_designated_init" != "yes"; then
+ AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
+fi
+
AC_PATH_PROG([SHA1SUM], [sha1sum], none)
AC_PATH_PROG([OPENSSL], [openssl], none)
@@ -1500,7 +1522,7 @@ if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xy
if test x$have_gcc4 = xyes ; then
# These warnings break gcc 3.3.5 and work on gcc 4.0.2
- CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
+ CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wold-style-definition"
fi
if test x$have_gcc42 = xyes ; then
More information about the tor-commits
mailing list