bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: getpass: Fix compilation error on Android
Date: Thu, 05 Jan 2023 17:18:41 +0100	[thread overview]
Message-ID: <3510174.kGzlxMrEDr@nimes> (raw)

On Android, I'm seeing this compilation error:

clang -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -DNO_XMALLOC -DEXEEXT=\"\" -I. -I../../gllib -I..  -DGNULIB_STRICT_CHECKING=1 -I/data/data/com.termux/files/home/local/include -Wall -fvisibility=hidden -O2 -c -o getpass.o ../../gllib/getpass.c
../../gllib/getpass.c:85:1: error: redefinition of 'getpass'
getpass (const char *prompt)
^
/data/data/com.termux/files/usr/include/unistd.h:419:25: note: previous definition is here
static __inline__ char* getpass(const char* prompt) {
                        ^
1 error generated.
make[3]: *** [Makefile:10690: getpass.o] Error 1

The cause is that Android's <unistd.h> defines getpass() as an inline function.
This should better be avoided.


2023-01-05  Bruno Haible  <bruno@clisp.org>

	getpass: Fix compilation error on Android.
	* m4/getpass.m4 (gl_FUNC_GETPASS): Define NO_INLINE_GETPASS.
	* doc/glibc-functions/getpass.texi: Mention the Android problem.

diff --git a/doc/glibc-functions/getpass.texi b/doc/glibc-functions/getpass.texi
index 17f1b2374b..8d2ff847ee 100644
--- a/doc/glibc-functions/getpass.texi
+++ b/doc/glibc-functions/getpass.texi
@@ -22,6 +22,10 @@ Portability problems fixed by either Gnulib module @code{getpass} or @code{getpa
 @item
 This function is missing on some platforms:
 mingw, MSVC 14, Android 9.0.
+@item
+This function cannot be called from plain inline or extern inline functions
+on some platforms:
+Android 13.
 @end itemize
 
 Portability problems fixed by Gnulib module @code{getpass-gnu}:
diff --git a/m4/getpass.m4 b/m4/getpass.m4
index 15882712d9..2dce1e0dfe 100644
--- a/m4/getpass.m4
+++ b/m4/getpass.m4
@@ -1,4 +1,4 @@
-# getpass.m4 serial 17
+# getpass.m4 serial 18
 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2023 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -13,6 +13,9 @@ AC_DEFUN_ONCE([gl_FUNC_GETPASS],
   dnl Persuade Solaris <unistd.h> and <stdlib.h> to declare getpass().
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
+  dnl Persuade Android <unistd.h> to not define getpass() as an inline function.
+  AC_DEFINE([NO_INLINE_GETPASS], [1], [Define to 1 on Android.])
+
   AC_CHECK_FUNCS_ONCE([getpass])
   if test $ac_cv_func_getpass = no; then
     HAVE_GETPASS=0





                 reply	other threads:[~2023-01-05 17:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3510174.kGzlxMrEDr@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).