]> Savannah Git Hosting - gnulib.git/commitdiff
Avoid redefinition errors on MSVC.
authorBruno Haible <bruno@clisp.org>
Sat, 17 Dec 2016 13:16:50 +0000 (14:16 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 17 Dec 2016 22:08:58 +0000 (23:08 +0100)
* lib/stdio.in.h: Include <stdlib.h> and <io.h> when necessary.
* lib/unistd.in.h: Include <stdio.h> when necessary.

ChangeLog
lib/stdio.in.h
lib/unistd.in.h

index 09c238ab67ecf829897a4526f7f9ce51c48c8f15..68912522ecbb2d4c952d38a0159f9eb3d861ce76 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-12-17  Bruno Haible  <bruno@clisp.org>
+
+       Avoid redefinition errors on MSVC.
+       * lib/stdio.in.h: Include <stdlib.h> and <io.h> when necessary.
+       * lib/unistd.in.h: Include <stdio.h> when necessary.
+
 2016-12-17  Bruno Haible  <bruno@clisp.org>
 
        stdint: Fix WINT_MAX to match the gnulib provided wint_t on MSVC.
index 4a6e9ff401079f2c3eda87c7ba97c13ed7570857..fff16a55f2ce72fd3e8b084b32137646b1ee7fe7 100644 (file)
 # include <unistd.h>
 #endif
 
+/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>.  We must include
+   it before we  #define perror rpl_perror.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
+    && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
+    && ! defined __GLIBC__
+# include <stdlib.h>
+#endif
+
+/* MSVC declares 'remove' in <io.h>, not in <stdio.h>.  We must include
+   it before we  #define remove rpl_remove.  */
+/* MSVC declares 'rename' in <io.h>, not in <stdio.h>.  We must include
+   it before we  #define rename rpl_rename.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
+    && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
+    && ! defined __GLIBC__
+# include <io.h>
+#endif
+
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
index 686eb818c20d21ec2ef3c0585e183590358d880a..e7e977c16fe34141e2eafd84848cbef5b9299c5d 100644 (file)
 #include <stddef.h>
 
 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
+/* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>.  We must include
+   it before we  #define unlink rpl_unlink.  */
 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>.  */
 /* But avoid namespace pollution on glibc systems.  */
 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
+     || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
+         && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) \
      || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
          && defined __CYGWIN__)) \
     && ! defined __GLIBC__