]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
fcntl-h, unistd-h: Fix errors in C++ mode with MSVC.
authorBruno Haible <bruno@clisp.org>
Sun, 25 May 2025 19:00:49 +0000 (21:00 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 25 May 2025 19:00:49 +0000 (21:00 +0200)
* lib/fcntl.in.h (open): Use _GL_CXXALIAS_MDA_CAST instead of
_GL_CXXALIAS_MDA.
* lib/unistd.in.h: Include <io.h>, <direct.h> before <fcntl.h>.

ChangeLog
lib/fcntl.in.h
lib/unistd.in.h

index a024ef7e40cd94e02c46f1321e1c18699f52a95c..d42ae4954be74773ae7f2671958604c465528d9c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-05-25  Bruno Haible  <bruno@clisp.org>
+
+       fcntl-h, unistd-h: Fix errors in C++ mode with MSVC.
+       * lib/fcntl.in.h (open): Use _GL_CXXALIAS_MDA_CAST instead of
+       _GL_CXXALIAS_MDA.
+       * lib/unistd.in.h: Include <io.h>, <direct.h> before <fcntl.h>.
+
 2025-05-25  Bruno Haible  <bruno@clisp.org>
 
        utime-h: Fix error in C++ mode with MSVC.
index d7f551b30f3f2a0fa57c1b10c12f4eea41a9b89e..0e4c04ea9b84404ca71df4bffd40189fb99671ed 100644 (file)
@@ -209,7 +209,9 @@ _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
 #   undef open
 #   define open _open
 #  endif
-_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
+/* Need to cast, because in MSVC the parameter list of _open as a C++ function
+   is (const char *, int, int = 0).  */
+_GL_CXXALIAS_MDA_CAST (open, int, (const char *filename, int flags, ...));
 # else
 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
 # endif
index c135a770dc1fe3647b745c847c2b74b0e14a4564..9f057d30cdf81c8e4a70401090e413fd9cf51eae 100644 (file)
 # include <stdio.h>
 #endif
 
+/* Native Windows platforms declare _chdir, _getcwd, _rmdir in
+   <io.h> and/or <direct.h>, not in <unistd.h>.
+   They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(),
+   _lseek(), _read(), _unlink(), _write() in <io.h>.  */
+#if defined _WIN32 && !defined __CYGWIN__
+# include <io.h>
+# include <direct.h>
+#endif
+
 /* FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, and glibc 2.41
    do not define O_CLOEXEC in <unistd.h>.  */
 /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
 # undef __need_system_stdlib_h
 #endif
 
-/* Native Windows platforms declare _chdir, _getcwd, _rmdir in
-   <io.h> and/or <direct.h>, not in <unistd.h>.
-   They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(),
-   _lseek(), _read(), _unlink(), _write() in <io.h>.  */
-#if defined _WIN32 && !defined __CYGWIN__
-# include <io.h>
-# include <direct.h>
-#endif
-
 /* Native Windows platforms declare _execl*, _execv* in <process.h>.  */
 #if defined _WIN32 && !defined __CYGWIN__
 # include <process.h>