[m-rev.] diff: fix build error on MinGW systems

Julien Fischer jfischer at opturion.com
Thu May 1 12:29:26 AEST 2014


Branches: 14.01, master

==============================================

Fix a build error on MinGW systems.

Some versions of the MinGW system headers rely on the types off_t and off64_t
being defined, but they will not be defined if -ansi is enabled.
(This seems to affect MinGW systems using GCC 4.8; I haven't checked other
GCC versions yet.)

configure.ac:
scripts/mgnuc.in:
 	Do not compile with -ansi on MinGW systems.

Julien.

diff --git a/configure.ac b/configure.ac
index a024ce8..c756fad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4582,7 +4582,14 @@ OPT_FLAGS_FOR_CLANG="-O0"
  case "$mercury_cv_cc_type" in

      gcc*)
-        CFLAGS_FOR_ANSI="-ansi"
+        # 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

          # 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 fc1833b..e8df6dc 100644
--- a/scripts/mgnuc.in
+++ b/scripts/mgnuc.in
@@ -26,6 +26,7 @@ CFLAGS_FOR_REGS="@CFLAGS_FOR_REGS@"
  CFLAGS_FOR_GOTOS="@CFLAGS_FOR_GOTOS@"
  CFLAGS_FOR_THREADS="@CFLAGS_FOR_THREADS@"
  CFLAGS_FOR_NO_STRICT_ALIASING="@CFLAGS_FOR_NO_STRICT_ALIASING@"
+CFLAGS_FOR_ANSI="@CFLAGS_FOR_ANSI@"
  AS="@AS@"
  BYTES_PER_WORD="@BYTES_PER_WORD@"
  MKTEMP=@MKTEMP@
@@ -33,7 +34,7 @@ TMPDIR=${TMPDIR=/tmp}

  case "$C_COMPILER_TYPE" in
      gcc*)
-        ANSI_OPTS="-ansi"
+        ANSI_OPTS="@CFLAGS_FOR_ANSI@"
          CHECK_OPTS="
              -Wall -Wwrite-strings
              -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wno-unused"



More information about the reviews mailing list