This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Stop including <malloc.h> in gcc/system.h


<malloc.h> is deprecated on some systems and we gets hundreds of
warnings due to including it on (at least) dragonfly and openbsd.

We already do this earlier in system.h:

#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif

/* When compiling C++ we need to include <cstdlib> as well as <stdlib.h> so
  that it is processed before we poison "malloc"; otherwise, if a source
  file uses a standard library header that includes <cstdlib>, we will get
  an error about 'using std::malloc'.  */
#ifdef __cplusplus
#include <cstdlib>
#endif

So if that doesn't already declare malloc/calloc/realloc then the
system is from the dark ages and including <malloc.h> is not likely to
be all that's needed to build a current GCC!

Bootstrapped on linux-gnu, openbsd5.0, dragonfly4.2, and aix7.1.2.0,
pre-approved by Richi on IRC, committed to trunk.


commit 5c1eeabb69319ed6fe6ab57621b6dd9a4ff0193b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Oct 2 12:25:07 2015 +0100

    	* system.h (malloc.h): Don't include obsolete header.

diff --git a/gcc/system.h b/gcc/system.h
index 71867c4..85a66a5 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -481,18 +481,6 @@ extern char *stpcpy (char *, const char *);
 int unsetenv(const char *);
 #endif
 
-#ifdef __cplusplus
-}
-#endif
-
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #if defined (HAVE_DECL_MALLOC) && !HAVE_DECL_MALLOC
 extern void *malloc (size_t);
 #endif

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]