bug-gnulib
[Top][All Lists]
Advanced

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

swab: Fix compilation error with Sun C++ on Solaris 11.3


From: Bruno Haible
Subject: swab: Fix compilation error with Sun C++ on Solaris 11.3
Date: Sun, 18 Sep 2022 02:32:55 +0200

On Solaris 11.3, with Sun C/C++, I see this compilation error:

CC -m64 -O -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I../../gltests -I..  
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. 
-I../../gltests/.. -I../gllib -I../../gltests/../gllib 
-I/export/home/haible/prefix-sparc64/include -D_REENTRANT  -g -c -o 
test-fcntl-h-c++.o ../../gltests/test-fcntl-h-c++.cc
...
"../gllib/unistd.h", line 2568: Error: Cannot return extern "C" void(*)(const 
void*,void*,long) from a function that should return void(*)(const 
char*,char*,long).
...
1 Error(s) and 72 Warning(s) detected.
gmake[3]: *** [Makefile:23350: test-fcntl-h-c++.o] Error 2

This patch fixes it. Tested on Solaris 10 and 11.3, both with Sun C/C++ and
with gcc/g++.

Recall that on Solaris 10, the Sun compilers define the preprocessor macro
__SunOS_5_10, whereas on Solaris 11, they define the preprocessor macro
__SunOS_5_11 (see <https://docs.oracle.com/cd/E24457_01/html/E22003/cc.1.html>).


2022-09-17  Bruno Haible  <bruno@clisp.org>

        swab: Fix compilation error with Sun C++ on Solaris 11.3.
        * lib/unistd.in.h (swab): For the C++ declaration, under Solaris 11 but
        not under Solaris 10, test also __XOPEN_OR_POSIX.

diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index ef3e68fcd2..50f6e56550 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -2057,7 +2057,7 @@ _GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, 
int n));
 # else
 #  if defined __hpux /* HP-UX */
 _GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
-#  elif defined __sun && !defined _XPG4 /* Solaris */
+#  elif defined __sun && (defined __SunOS_5_10 || defined __XOPEN_OR_POSIX) && 
!defined _XPG4 /* Solaris */
 _GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
 #  else
 _GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));






reply via email to

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