[m-rev.] diff: do not pass -ansi to GCC on any system
Julien Fischer
jfischer at opturion.com
Tue Sep 23 15:51:48 AEST 2014
Do not pass -ansi to GCC on any system.
Passing -ansi to GCC restricts us to the C90 dialect of C and prevents us from
using C99 library features with GCC. Since every version of GCC we support
provides the relevant C99 features there is not much point to imposing this
restriction. As already noted in the configure script the use of -ansi was
also causing problems with the header files on MinGW systems. Finally, I do
think it is reasonable to require users to use the C90 dialect of C in
foreign_proc and foreign_code pragma bodies by default.
NOTE: this is *not* an invitation to start using C99 language features
throughout the runtime and library -- at this point, we (unfortunately) still
maintain compatibility with older versions of MSVC that don't support these
features.
configure.ac:
Do not pass -ansi to GCC. Add an explanation of why.
scripts/mgnuc.in:
Update the description of the what the --no-ansi option does.
(XXX there's _a lot_ of out-of-date stuff in this script.)
Julien.
diff --git a/configure.ac b/configure.ac
index c8624c5..459a4a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4562,14 +4562,23 @@ OPT_FLAGS_FOR_CLANG="-O0"
case "$mercury_cv_cc_type" in
gcc*)
- # Do not use -ansi on MinGW systems because with some versions of the
- # system headers the types off_t and off64_t will not be defined with
- # that option, but they are required in other places in the system
- # headers.
- case "$host" in
- *mingw*) CFLAGS_FOR_ANSI= ;;
- *) CFLAGS_FOR_ANSI="-ansi" ;;
- esac
+ # We no longer pass -ansi to GCC on any system for the following
+ # reasons:
+ # * It restricts the dialect of C used to C90 and that prevents us
+ # from using various C99 library features. Every version of GCC we
+ # support provides those features so there is no point in doing
+ # this.
+ # * It causes complications with the header files on some systems.
+ # Notably with the definitions of the types off_t and off64_t on MinGW
+ # systems.
+ # * This setting also affects the compilation of user written C code in
+ # foreign_proc and and foreign code pragmas.
+ #
+ # NOTE: the --no-ansi option supported by the mgnuc script does more than
+ # simply pass the value of CFLAGS_FOR_ANSI to the C compiler.
+ # (See that script for details.)
+ #
+ CFLAGS_FOR_ANSI=
# For a full list of the other gcc warnings that we don't
# enable, and why, see scripts/mgnuc.in.
diff --git a/scripts/mgnuc.in b/scripts/mgnuc.in
index 2c8261d..33eaf46 100644
--- a/scripts/mgnuc.in
+++ b/scripts/mgnuc.in
@@ -133,8 +133,7 @@ Options:
-v, --verbose
Echo gcc command before executing it.
--no-ansi
- Don't pass \`-ansi' to gcc. Use the full contents of system headers,
- rather than the ANSI subset.
+ Use the full contents of system headers, rather than the ANSI subset.
--no-check
Don't enable any of gcc's warnings.
--low-level-debug
More information about the reviews
mailing list