bug-gnulib
[Top][All Lists]
Advanced

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

uchar: Work around error in C++ mode on AIX 7.2 with xlclang


From: Bruno Haible
Subject: uchar: Work around error in C++ mode on AIX 7.2 with xlclang
Date: Sat, 10 Sep 2022 18:59:27 +0200

On AIX 7.2 with xlclang, I also see this compilation error:

depbase=`echo test-uchar-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
xlclang++ -qthreaded -qtls -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/home/haible/prefix32/include -D_THREAD_SAFE  -Wno-error -g -O2 -MT 
test-uchar-c++.o -MD -MP -MF $depbase.Tpo -c -o test-uchar-c++.o 
../../gltests/test-uchar-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from ../../gltests/test-uchar-c++.cc:22:
In file included from ../gllib/uchar.h:32:
/usr/include/uchar.h:37:24: error: cannot combine with previous 'type-name' 
declaration specifier
typedef uint_least16_t char16_t;
                       ^
/usr/include/uchar.h:38:24: error: cannot combine with previous 'type-name' 
declaration specifier
typedef uint_least32_t char32_t;
                       ^
2 errors generated.
Error while processing ../../gltests/test-uchar-c++.cc.
Makefile:23408: recipe for target 'test-uchar-c++.o' failed
gmake[4]: *** [test-uchar-c++.o] Error 1

The cause is that in this situation, 'char16_t' and 'char32_t' are keywords.

This patch provides a workaround.


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

        uchar: Work around error in C++ mode on AIX 7.2 with xlclang.
        * lib/uchar.in.h (char16_t, char32_t): On AIX with xlclang++, define
        these as macros.
        * doc/posix-headers/uchar.texi: Document the AIX + xlclang++ bug.

diff --git a/doc/posix-headers/uchar.texi b/doc/posix-headers/uchar.texi
index ce5ecaf6a8..945ce665fd 100644
--- a/doc/posix-headers/uchar.texi
+++ b/doc/posix-headers/uchar.texi
@@ -12,6 +12,9 @@ Portability problems fixed by Gnulib:
 @item
 This header file is missing on many non-glibc platforms:
 glibc 2.15, macOS 11.1, FreeBSD 6.4, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 
7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.3, Cygwin, mingw, MSVC 9.
+@item
+This file produces compilation errors in C++ mode on some platforms:
+AIX 7.2 with xlclang++.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/lib/uchar.in.h b/lib/uchar.in.h
index e6a5cddf86..15fd7bc1eb 100644
--- a/lib/uchar.in.h
+++ b/lib/uchar.in.h
@@ -28,6 +28,14 @@
 @PRAGMA_COLUMNS@
 
 #if @HAVE_UCHAR_H@
+/* On AIX 7.2 with xlclang++, /usr/include/uchar.h produces compilation errors
+   because it contains typedef definitions of char16_t and char32_t, however
+   char16_t and char32_t are keywords in this situation.  To work around it,
+   define char16_t and char32_t as macros.  */
+# if defined __cplusplus && defined _AIX && defined __ibmxl__ && defined 
__clang__
+#  define char16_t gl_char16_t
+#  define char32_t gl_char32_t
+# endif
 # @INCLUDE_NEXT@ @NEXT_UCHAR_H@
 #endif
 






reply via email to

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