Today's source cannot build on NetBSD

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Fri Jan 7 10:10:00 GMT 2000


 > From: Krister Walfridsson <cato at df dot lth dot se> 
 >       Date: Wed, 29 Dec 1999 23:09:59 +0100 (CET) 
 > 
 > ../../egcs/gcc/../include/libiberty.h:194: conflicting types for `vasprintf'
 > /usr/include/stdio.h:348: previous declaration of `vasprintf'
 > 
 > The vasprintf in /usr/include/stdio.h is declared as
 > int      vasprintf __P((char **, const char *, _BSD_VA_LIST_))
 >                 __attribute__((__format__(__printf__, 2, 0)));
 >    /Krister


I don't have access to a netbsd system, but I notice that in
libiberty/vasprintf.c the function is declared as:

 > int
 > vasprintf (result, format, args)
 >      char **result;
 >      const char *format;
 > #if defined (_BSD_VA_LIST_) && defined (__FreeBSD__)
 >      _BSD_VA_LIST_ args;
 > #else
 >      va_list args;
 > #endif

So perhaps it would be proper to declare it like that in the
libiberty.h header file?  Does netbsd define __FreeBSD__ ?

Does this patch fix things for you?

If it does, can you or anyone explain why _BSD_VA_LIST_ exists?  Do
the other v*printf functions use it too?  What happens if you pass a
va_list to vasprintf?  I.e. can you compile gcc/f/{com.c,sts.c} ?
(Those files use vasprintf and pass it a va_list.)

		Thanks,
	 	--Kaveh

--- libiberty.h.orig	Fri Jan  7 13:05:48 2000
+++ libiberty.h	Fri Jan  7 13:07:13 2000
@@ -190,8 +190,13 @@ extern int asprintf PARAMS ((char **, co
 /* 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);
+extern int vasprintf
+#if defined (_BSD_VA_LIST_) && defined (__FreeBSD__)
+  PARAMS ((char **, const char *, _BSD_VA_LIST_))
+#else
+  PARAMS ((char **, const char *, va_list))
+#endif
+    ATTRIBUTE_PRINTF(2,0);
 
 #ifdef __cplusplus
 }


More information about the Gcc-bugs mailing list