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]

libiberty: don't redeclare vasprintf nor asprintf


Building C++ applications that include libiberty.h may be a problem
using recent version of glibc that declare vasprintf and asprintf with
throw(), since then the declarations in libiberty.h conflict.  This
patch fixes the problem, as long as configure of the affected C++
package checks for declarations of these functions.

Verified to build in athlon-pc-linux-gnu.  Ok to install?

Index: include/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* libiberty.h (asprintf, vasprintf): Don't declare them if the
	corresponding HAVE_DECL_ macro is 1.

Index: include/libiberty.h
===================================================================
RCS file: /cvs/gcc/egcs/include/libiberty.h,v
retrieving revision 1.28
diff -u -p -r1.28 libiberty.h
--- include/libiberty.h 24 Jun 2002 05:08:02 -0000 1.28
+++ include/libiberty.h 19 Sep 2002 23:58:31 -0000
@@ -264,16 +264,20 @@ extern int pexecute PARAMS ((const char 
 
 extern int pwait PARAMS ((int, int *, int));
 
+#if !HAVE_DECL_ASPRINTF
 /* Like sprintf but provides a pointer to malloc'd storage, which must
    be freed by the caller.  */
 
 extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2;
+#endif
 
+#if !HAVE_DECL_VASPRINTF
 /* Like vsprintf but provides a pointer to malloc'd storage, which
    must be freed by the caller.  */
 
 extern int vasprintf PARAMS ((char **, const char *, va_list))
   ATTRIBUTE_PRINTF(2,0);
+#endif
 
 #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
 
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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