bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getlogin_r tests: Fix compilation error on some OpenSolaris derivatives


From: Bruno Haible
Subject: getlogin_r tests: Fix compilation error on some OpenSolaris derivatives
Date: Sat, 20 Apr 2024 01:15:25 +0200

Building a testdir on Solaris 11 SmartOS
(with CC="clang -O2 -D_XOPEN_SOURCE=700"), I see a compilation error:

../../gltests/test-getlogin_r.c:24:1: error: incompatible function pointer 
types initializing 'int (*)(char *, size_t)' (aka 'int (*)(char *, unsigned 
long)') with an expression of type 'int (char *, int)' 
[-Wincompatible-function-pointer-types]
SIGNATURE_CHECK (getlogin_r, int, (char *, size_t));
^                ~~~~~~~~~~
../../gltests/signature.h:39:3: note: expanded from macro 'SIGNATURE_CHECK'
  SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
  ^                 ~~
../../gltests/signature.h:44:3: note: expanded from macro 'SIGNATURE_CHECK1'
  SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */
  ^                 ~~
../../gltests/signature.h:46:27: note: expanded from macro 'SIGNATURE_CHECK2'
  _GL_UNUSED static ret (*signature_check ## id) args = fn
                          ^                             ~~
<scratch space>:115:1: note: expanded from here
signature_check24
^
1 error generated.
gmake[4]: *** [Makefile:25729: test-getlogin_r.o] Error 1

Unlike the similar errors for the functions accept, gethostname, getpeername,
getsockname, getsockopt, recvfrom, which go away by -D_XOPEN_SOURCE=700, this
one persists. Here's a workaround.


2024-04-19  Bruno Haible  <bruno@clisp.org>

        getlogin_r tests: Fix compilation error on some OpenSolaris derivatives.
        * tests/test-getlogin_r.c (getlogin_r): Don't check the signature on
        Solaris.

diff --git a/tests/test-getlogin_r.c b/tests/test-getlogin_r.c
index 73526bc1a9..e74aae3306 100644
--- a/tests/test-getlogin_r.c
+++ b/tests/test-getlogin_r.c
@@ -21,7 +21,9 @@
 #include <unistd.h>
 
 #include "signature.h"
+#if !defined __sun /* On Solaris, the second parameter is of type 'int'.  */
 SIGNATURE_CHECK (getlogin_r, int, (char *, size_t));
+#endif
 
 #include "test-getlogin.h"
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]