Hello,

This one makes system.h pull in <cstdlib> when compiling as C++.
It fixes issues when e.g. including <algorithm>.
Tested on my SH cross compiler config with 'make all-gcc', after
including the following std headers in one of the RTL passes:
<algorithm> <limits> <bitset> <cassert> <cctype> <cerrno> <cfloat>
<climits> <clocale> <cmath> <complex> <csetjmp> <csignal> <cstdarg>
<cstddef> <cstdio> <cstdlib> <cstring> <ctime> <deque>e <exception>
<fstream> <functional> <iomanip> <ios> <iosfwd> <iostream> <istream>
<iterator> <limits> <list> <locale> <map> <memory> <new>e <numeric>
<ostream> <queue> <set> <sstream> <stack> <stdexcept> <strstream>
<streambuf> <string> <typeinfo> <utility> <valarray> <vector>.

My host GCC is:
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --enable-plugin --enable-objc-gc
--enable-targets=all --disable-werror --with-arch-32=i686
--with-tune=generic --enable-checking=release --build=i686-linux-gnu
--host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

Cheers,
Oleg

ChangeLog:

        * system.h: Include <cstdlib> instead of <stdlib.h> when
        compiling as C++.
Index: gcc/system.h
===================================================================
--- gcc/system.h	(revision 190665)
+++ gcc/system.h	(working copy)
@@ -224,8 +224,12 @@
 # endif
 #endif
 
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
+#ifdef __cplusplus
+# include <cstdlib>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
 #endif
 
 /* If we don't have an overriding definition, set SUCCESS_EXIT_CODE and

Reply via email to