On Solaris 10, with the Sun Studio 11 'CC' (a.k.a. SunPRO C++),
I see this compilation error:

CC -O -DHAVE_CONFIG_H -DEXEEXT=\"\" -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/prefix-x86/include -D_REENTRANT  -g -c -o test-nullptr-c++.o 
../../gltests/test-nullptr-c++.cc
"../../gltests/test-nullptr-c++.cc", line 38: Error: The function 
"print_stack_trace" must have a prototype.
"../../gltests/test-nullptr-c++.cc", line 42: Error: The function 
"print_stack_trace" must have a prototype.
"../../gltests/test-nullptr-c++.cc", line 45: Error: The function 
"print_stack_trace" must have a prototype.
"../../gltests/test-nullptr-c++.cc", line 48: Error: The function 
"print_stack_trace" must have a prototype.
4 Error(s) detected.

What's happening is:
  * The module 'stack-trace' is in use. It ought to declare the
    print_stack_trace() function in stdlib.h.
  * stdlib.h is included twice:
    - from unistd.h, with __need_system_stdlib_h defined,
    - then from macros.h, with __need_system_stdlib_h no longer defined.
  * "CC -E -H" shows the list of includes, and it is clear that the
    '#include <stdlib.h>' from tests/macros.h is ineffective because there
    was already a '#include <stdlib.h>' earlier.
    (The same effect does not happen always. For example, ../gllib/sys/types.h
    is included many times.) 

So, we have to make sure that the first '#include <stdlib.h>' already
includes the entire file, including the 'print_stack_trace' declaration.


2024-09-16  Bruno Haible  <br...@clisp.org>

        stdlib: Fix compilation error with Sun C++.
        * lib/stdlib.in.h: Don't obey the special invocation convention when
        Sun C++ is used.

diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index e6c5123713..6667f426ad 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -20,7 +20,9 @@
 #endif
 @PRAGMA_COLUMNS@
 
-#if (defined __need_system_stdlib_h && !defined _GLIBCXX_STDLIB_H) || defined 
__need_malloc_and_calloc
+#if ((defined __need_system_stdlib_h && !defined _GLIBCXX_STDLIB_H) \
+     || defined __need_malloc_and_calloc) \
+    && !defined __SUNPRO_CC
 /* Special invocation conventions inside some gnulib header files,
    and inside some glibc header files, respectively.
    Do not recognize this special invocation convention when GCC's




Reply via email to