[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
getlogin on mingw
From: |
Bruno Haible |
Subject: |
getlogin on mingw |
Date: |
Sat, 17 Dec 2016 12:08:09 +0100 |
User-agent: |
KMail/4.8.5 (Linux/3.8.0-44-generic; KDE/4.8.5; x86_64; ; ) |
I'm seeing this compilation failure on a recent mingw:
In file included from ../../gltests/test-getlogin.c:23:0:
../../gltests/test-getlogin.c:24:18: error: ‘getlogin’ undeclared here (not in
a function)
SIGNATURE_CHECK (getlogin, char *, (void));
^
../../gltests/signature.h:46:58: note: in definition of macro ‘SIGNATURE_CHECK2’
static ret (* _GL_UNUSED signature_check ## id) args = fn
^
../../gltests/signature.h:39:3: note: in expansion of macro ‘SIGNATURE_CHECK1’
SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
^
../../gltests/test-getlogin.c:24:1: note: in expansion of macro
‘SIGNATURE_CHECK’
SIGNATURE_CHECK (getlogin, char *, (void));
^
../../gltests/test-getlogin.c:31:17: fatal error: pwd.h: No such file or
directory
compilation terminated.
make[4]: *** [Makefile:7987: test-getlogin.o] Error 1
The reason is that getlogin exists, but is only declared in <io.h> and only
with -D_POSIX, which I'd prefer to not turn on. And a regression from
2014-05-14.
This fixes it.
2016-12-17 Bruno Haible <address@hidden>
getlogin: Port to newer mingw.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize HAVE_DECL_GETLOGIN.
* m4/getlogin.m4 (gl_FUNC_GETLOGIN): Set HAVE_DECL_GETLOGIN.
* modules/unistd (Makefile.am): Substibute HAVE_DECL_GETLOGIN, not
HAVE_GETLOGIN.
* lib/unistd.in.h (getlogin): Test HAVE_DECL_GETLOGIN, not
HAVE_GETLOGIN.
* doc/posix-functions/getlogin.texi: Mention the issue.
* tests/test-getlogin.c: Don't include <pwd.h> on native Windows. Fixes
regression introduced on 2014-05-14.
diff --git a/doc/posix-functions/getlogin.texi
b/doc/posix-functions/getlogin.texi
index 2569eb1..73e961c 100644
--- a/doc/posix-functions/getlogin.texi
+++ b/doc/posix-functions/getlogin.texi
@@ -10,7 +10,10 @@ Portability problems fixed by Gnulib:
@itemize
@item
This function is missing on some platforms:
-mingw, MSVC 9.
+older mingw, MSVC 9.
address@hidden
+This function is not declared unless @code{_POSIX} is defined on some
platforms:
+mingw.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 61250c9..686eb81 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -776,7 +776,7 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
${LOGNAME-$USER} on Unix platforms,
$USERNAME on native Windows platforms.
*/
-# if address@hidden@
+# if address@hidden@
_GL_FUNCDECL_SYS (getlogin, char *, (void));
# endif
_GL_CXXALIAS_SYS (getlogin, char *, (void));
diff --git a/m4/getlogin.m4 b/m4/getlogin.m4
index b3b2655..a03193b 100644
--- a/m4/getlogin.m4
+++ b/m4/getlogin.m4
@@ -1,4 +1,4 @@
-# getlogin.m4 serial 3
+# getlogin.m4 serial 4
dnl Copyright (C) 2010-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,6 +7,10 @@ dnl with or without modifications, as long as this notice is
preserved.
AC_DEFUN([gl_FUNC_GETLOGIN],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ AC_CHECK_DECLS_ONCE([getlogin])
+ if test $ac_cv_have_decl_getlogin = no; then
+ HAVE_DECL_GETLOGIN=0
+ fi
AC_CHECK_FUNCS_ONCE([getlogin])
if test $ac_cv_func_getlogin = no; then
HAVE_GETLOGIN=0
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index 544dadb..46ff109 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 68
+# unistd_h.m4 serial 69
dnl Copyright (C) 2006-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -145,6 +145,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR])
HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC])
HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
+ HAVE_DECL_GETLOGIN=1; AC_SUBST([HAVE_DECL_GETLOGIN])
HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
diff --git a/modules/unistd b/modules/unistd
index 1619509..8af837c 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -99,7 +99,6 @@ unistd.h: unistd.in.h $(top_builddir)/config.status
$(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
-e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
-e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
- -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
-e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
-e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \
-e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
@@ -121,6 +120,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status
$(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
-e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \
-e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g'
\
+ -e 's|@''HAVE_DECL_GETLOGIN''@|$(HAVE_DECL_GETLOGIN)|g' \
-e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
-e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
-e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c
index 6e1b64c..ed04c8c 100644
--- a/tests/test-getlogin.c
+++ b/tests/test-getlogin.c
@@ -28,7 +28,9 @@ SIGNATURE_CHECK (getlogin, char *, (void));
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <pwd.h>
+#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
+# include <pwd.h>
+#endif
#include <sys/stat.h>
#include <sys/types.h>
- getlogin on mingw,
Bruno Haible <=