bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* aligned_alloc: Fix compilation error in C++ mode on Solaris 11
@ 2022-09-02 18:12 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2022-09-02 18:12 UTC (permalink / raw
  To: bug-gnulib

A gnulib testdir produces a compilation error on Solaris 11 OmniOS:

In file included from /usr/include/sys/time.h:489,
                 from ../gllib/sys/time.h:39,
                 from /usr/include/sys/select.h:53,
                 from ../gllib/sys/select.h:36,
                 from /usr/include/sys/types.h:640,
                 from ../gllib/sys/types.h:39,
                 from /usr/include/malloc.h:31,
                 from ../gllib/malloc.h:27,
                 from ../../gltests/test-malloc-h-c++.cc:22:
../gllib/stdlib.h:782:1: error: 'aligned_alloc' was not declared in this scope
  782 | _GL_CXXALIASWARN (aligned_alloc);
      | ^~~~~~~~~~~~~~~~
../gllib/stdlib.h:782:1: note: suggested alternatives:
In file included from /usr/include/stdlib.h:42,
                 from /opt/gcc-9/include/c++/9.3.0/cstdlib:75,
                 from /opt/gcc-9/include/c++/9.3.0/stdlib.h:36,
                 from ../gllib/stdlib.h:36,
                 from ../gllib/malloc.h:35,
                 from ../../gltests/test-malloc-h-c++.cc:22:
/usr/include/iso/stdlib_c11.h:60:14: note:   'std::aligned_alloc'
   60 | extern void *aligned_alloc(size_t, size_t);
      |              ^~~~~~~~~~~~~
In file included from /usr/include/sys/time.h:489,
                 from ../gllib/sys/time.h:39,
                 from /usr/include/sys/select.h:53,
                 from ../gllib/sys/select.h:36,
                 from /usr/include/sys/types.h:640,
                 from ../gllib/sys/types.h:39,
                 from /usr/include/malloc.h:31,
                 from ../gllib/malloc.h:27,
                 from ../../gltests/test-malloc-h-c++.cc:22:
../gllib/stdlib.h:769:1: note:   'gnulib::aligned_alloc'
  769 | _GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
      | ^~~~~~~~~~~~~~~~

The reason is that aligned_alloc is not declared in C++ mode, only in ISO C11
mode. This patch fixes the error:


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

	aligned_alloc: Fix compilation error in C++ mode on Solaris 11.
	* lib/stdlib.in.h (aligned_alloc): Enable the C++ alias warning only on
	glibc systems.

diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index a86643c3ca..010875803c 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -226,7 +226,7 @@ _GL_FUNCDECL_SYS (aligned_alloc, void *,
 _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
 #  endif
 # endif
-# if @HAVE_ALIGNED_ALLOC@
+# if (__GLIBC__ >= 2) && @HAVE_ALIGNED_ALLOC@
 _GL_CXXALIASWARN (aligned_alloc);
 # endif
 #else





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-02 18:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-02 18:12 aligned_alloc: Fix compilation error in C++ mode on Solaris 11 Bruno Haible

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).