From afc48f8939b99a1a72b43b3e342d56193ed1f34c Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Mon, 28 Mar 2016 14:34:22 +0200 Subject: Autoconf: detect and set CFLAGS/CPPFLAGS needed for C99 mode This is the first phase of addressing #11757 which aims to make C99 support a base-line requirement for GHC and clean up the code-base to use C99 facilities when sensible. This patch exploits the logic/heuristic used by `AC_PROG_CC_C99` to determine the flags needed in case the C compiler isn't able to compile C99 code in its current mode. We can't use `AC_PROG_CC_C99` directly though because GHC's build-system expects CC to contain a filename without any flags, while `AC_PROG_CC_C99` would e.g. result in `CC="gcc -std=gnu99"`. Morever, we support different `CC`s for stage0/1/2, so we need a version of `AC_PROG_CC_C99` for which we can specify the `CC`/`CFLAGS` variables to operate on. This is what `FP_SET_CFLAGS_C99` does. Note that Clang has been defaulting to C99+ for a long time, while GCC 5 defaults to C99+ as well. So this has mostly an affect on older GCCs versions prior to 5.0 and possibly compilers other than GCC/Clang (which are not officially supported for building GHC anyway). Reviewers: kgardas, erikd, bgamari, austin Reviewed By: erikd Differential Revision: https://phabricator.haskell.org/D2045 --- includes/Stg.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'includes/Stg.h') diff --git a/includes/Stg.h b/includes/Stg.h index b179db6deb..f1949b1630 100644 --- a/includes/Stg.h +++ b/includes/Stg.h @@ -26,6 +26,10 @@ #ifndef STG_H #define STG_H +#if !(__STDC_VERSION__ >= 199901L) +# error __STDC_VERSION__ does not advertise C99 or later +#endif + /* * If we are compiling a .hc file, then we want all the register * variables. This is the what happens if you #include "Stg.h" first: -- cgit v1.2.1