clang on native Windows shows a warning: gllib\write-any-file.c(44,14): warning: implicit declaration of function 'geteuid' is invalid in C99 [-Wimplicit-function-declaration]
geteuid does not exist on native Windows. Let's do like in tests/test-access.h. This patch should fix the issue. 2024-08-27 Bruno Haible <br...@clisp.org> write-any-file: Don't reference an undefined function on native Windows. * m4/write-any-file.m4 (): Remove test for <priv.h>, obsolete since 2009-05-03. Test for geteuid. * lib/write-any-file.c (geteuid): Define a fallback. diff --git a/lib/write-any-file.c b/lib/write-any-file.c index 27ca2c47c5..d1f98471a9 100644 --- a/lib/write-any-file.c +++ b/lib/write-any-file.c @@ -19,11 +19,18 @@ #include <config.h> +/* Specification. */ #include "write-any-file.h" + +#include <unistd.h> + #include "priv-set.h" #include "root-uid.h" -#include <unistd.h> +/* mingw and MSVC 9 lack geteuid, so setup a dummy value. */ +#if !HAVE_GETEUID +# define geteuid() ROOT_UID +#endif /* Return true if we know that we can write any file, including writing directories. */ diff --git a/m4/write-any-file.m4 b/m4/write-any-file.m4 index 50e5aa0c2a..621d9b9e41 100644 --- a/m4/write-any-file.m4 +++ b/m4/write-any-file.m4 @@ -1,5 +1,5 @@ # write-any-file.m4 -# serial 1 +# serial 2 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,5 +11,5 @@ AC_DEFUN([gl_WRITE_ANY_FILE], [ - AC_CHECK_HEADERS_ONCE([priv.h]) + AC_CHECK_FUNCS_ONCE([geteuid]) ])