From f32d60edb8a3325e27953787b7fb9f051423b6bc Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 16 Mar 2016 19:13:19 +0200 Subject: Fix compilation errors and warnings with MinGW 3.21 and later. --- pc/ChangeLog | 12 ++++++++++++ pc/Makefile | 8 ++++---- pc/gawkmisc.pc | 4 ++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pc/ChangeLog b/pc/ChangeLog index fb44a486..5a7d9676 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,15 @@ +2016-03-16 Eli Zaretskii + + * gawkmisc.pc (usleep): Condition on MinGW runtime version older + than 3.21, which defines 'usleep' as an inline function in + unistd.h, and thus causes compilation errors due to conflicting + definitions. Reported by Ivan Suchý . + + * Makefile (mingw32, mingw32-readline, mingw32-mpfr) + (mingw32-readline-mpfr): Use -Wno-deprecated-declarations, to + avoid warnings about 'usleep' in newer versions of mingw.org's + MinGW runtime. + 2015-05-29 Arnold D. Robbins * Makefile.tst (negtime): Sync with mainline. diff --git a/pc/Makefile b/pc/Makefile index d1c08069..23b90464 100644 --- a/pc/Makefile +++ b/pc/Makefile @@ -168,28 +168,28 @@ LMINGW32 = $(CC) $(LF) -o $@ $(GAWKOBJS) $(LF2) mingw32: $(MAK) all \ - CC=gcc O=.o CF="-D__USE_MINGW_ANSI_STDIO -O2 -gdwarf-2 -g3" \ + CC=gcc O=.o CF="-D__USE_MINGW_ANSI_STDIO -O2 -gdwarf-2 -g3 -Wno-deprecated-declarations" \ OBJ=popen.o LNK=LMINGW32 LF="-gdwarf-2 -g3" \ LF2="-lws2_32 -lmsvcp60" RSP= mingw32-readline: $(MAK) all \ CC=gcc O=.o \ - CF="-D__USE_MINGW_ANSI_STDIO -DHAVE_LIBREADLINE -O2 -gdwarf-2 -g3" \ + CF="-D__USE_MINGW_ANSI_STDIO -DHAVE_LIBREADLINE -O2 -gdwarf-2 -g3 -Wno-deprecated-declarations" \ OBJ=popen.o LNK=LMINGW32 LF="-gdwarf-2 -g3" \ LF2="-lreadline -lws2_32 -lmsvcp60 -Wl,--enable-auto-import" RSP= mingw32-mpfr: $(MAK) all \ CC=gcc O=.o \ - CF="-D__USE_MINGW_ANSI_STDIO -DHAVE_MPFR -O2 -gdwarf-2 -g3" \ + CF="-D__USE_MINGW_ANSI_STDIO -DHAVE_MPFR -O2 -gdwarf-2 -g3 -Wno-deprecated-declarations" \ OBJ=popen.o LNK=LMINGW32 LF="-gdwarf-2 -g3" \ LF2="-lmpfr -lgmp -lws2_32 -lmsvcp60 -Wl,--enable-auto-import" RSP= mingw32-readline-mpfr: $(MAK) all \ CC=gcc O=.o \ - CF="-D__USE_MINGW_ANSI_STDIO -DHAVE_LIBREADLINE -DHAVE_MPFR -O2 -gdwarf-2 -g3" \ + CF="-D__USE_MINGW_ANSI_STDIO -DHAVE_LIBREADLINE -DHAVE_MPFR -O2 -gdwarf-2 -g3 -Wno-deprecated-declarations" \ OBJ=popen.o LNK=LMINGW32 LF="-gdwarf-2 -g3" \ LF2="-lmpfr -lgmp -lreadline -lws2_32 -lmsvcp60 -Wl,--enable-auto-import" RSP= diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc index fdd32e7e..486b1853 100644 --- a/pc/gawkmisc.pc +++ b/pc/gawkmisc.pc @@ -584,6 +584,9 @@ unsetenv (const char *name) return setenv (name, "", 1); } +/* MinGW 3.21 and later defines usleep as an inline function in + unistd.h, which conflicts with the version below. */ +#if __MINGW32_MAJOR_VERSION + (__MINGW32_MINOR_VERSION > 20) < 4 int usleep(unsigned int usec) { @@ -593,6 +596,7 @@ usleep(unsigned int usec) return usec - msecf * 1000 < 0 ? 0 : (int)(usec - msecf * 1000); } +#endif /* The implementation of wctob in the MS runtime is problematic because it doesn't allow to distinguish between WEOF and 0xff, due -- cgit v1.2.3