+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.
# 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
# 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>