From: Bruno Haible Date: Sun, 25 May 2025 19:00:49 +0000 (+0200) Subject: fcntl-h, unistd-h: Fix errors in C++ mode with MSVC. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=943396858e95f86699fb126a85f9f249e86b190a;p=thirdparty%2Fgnulib.git 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 , before . --- diff --git a/ChangeLog b/ChangeLog index a024ef7e40..d42ae4954b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2025-05-25 Bruno Haible + + 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 , before . + 2025-05-25 Bruno Haible utime-h: Fix error in C++ mode with MSVC. diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index d7f551b30f..0e4c04ea9b 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -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 diff --git a/lib/unistd.in.h b/lib/unistd.in.h index c135a770dc..9f057d30cd 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -95,6 +95,15 @@ # include #endif +/* Native Windows platforms declare _chdir, _getcwd, _rmdir in + and/or , not in . + They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(), + _lseek(), _read(), _unlink(), _write() in . */ +#if defined _WIN32 && !defined __CYGWIN__ +# include +# include +#endif + /* FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, and glibc 2.41 do not define O_CLOEXEC in . */ /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in , not in @@ -120,15 +129,6 @@ # undef __need_system_stdlib_h #endif -/* Native Windows platforms declare _chdir, _getcwd, _rmdir in - and/or , not in . - They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(), - _lseek(), _read(), _unlink(), _write() in . */ -#if defined _WIN32 && !defined __CYGWIN__ -# include -# include -#endif - /* Native Windows platforms declare _execl*, _execv* in . */ #if defined _WIN32 && !defined __CYGWIN__ # include