Attempt to sanitize the `vasprintf` situation in eglib.
authorAlex Rønne Petersen <alexrp@xamarin.com>
Tue, 10 Jun 2014 07:40:22 +0000 (09:40 +0200)
committerAlex Rønne Petersen <alexrp@xamarin.com>
Tue, 10 Jun 2014 07:40:22 +0000 (09:40 +0200)
The problem is that on some platforms we call the function
without having provided a prototype for it. This breaks when
building with `-Werror`.

Now we declare it in the private `vasprintf.h` header when
the platform doesn't have a declaration in `stdio.h`. This
should also let us remove the hack in `glib.h` for MSVC.

This may or may not break the build on some platforms; I've
tried on those that I have access to with success. Let me
know if this breaks anything.

eglib/src/gerror.c
eglib/src/glib.h
eglib/src/goutput.c
eglib/src/gstr.c
eglib/src/vasprintf.h [new file with mode: 0644]

index 790c388c7ad9fb6bb0230804ecbf4f3ef90f7dc4..2ec089c9956c1053c96bd0b8ea441d2881d54800 100644 (file)
@@ -30,6 +30,8 @@
 #include <string.h>
 #include <glib.h>
 
+#include "vasprintf.h"
+
 GError *
 g_error_new (gpointer domain, gint code, const char *format, ...)
 {
index cf54676312db4f770583d775782e3dfffff27794..30c2d7adb8f16791039c574f987da4c4c7df0b0c 100644 (file)
 
 G_BEGIN_DECLS
 
-#ifdef G_OS_WIN32
-/* MSC and Cross-compilatin will use this */
-int vasprintf (char **strp, const char *fmt, va_list ap);
-#endif
-
-
 /*
  * Basic data types
  */
index aff9f460c57c6ce3e675e00640e1d0ff01c396c5..73ef1f383dea0d572bd6ee5150c98673ad93ca4f 100644 (file)
@@ -31,6 +31,8 @@
 #include <stdlib.h>
 #include <glib.h>
 
+#include "vasprintf.h"
+
 /* The current fatal levels, error is always fatal */
 static GLogLevelFlags fatal = G_LOG_LEVEL_ERROR;
 
index 335ccff9365ba7ae6c3e6cec0a8d7f18083bd151..3e976c5a2edfe3019a294daad9f45d355f7da250 100644 (file)
@@ -32,6 +32,8 @@
 #include <ctype.h>
 #include <glib.h>
 
+#include "vasprintf.h"
+
 /* This is not a macro, because I dont want to put _GNU_SOURCE in the glib.h header */
 gchar *
 g_strndup (const gchar *str, gsize n)
diff --git a/eglib/src/vasprintf.h b/eglib/src/vasprintf.h
new file mode 100644 (file)
index 0000000..3d29454
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef __VASPRINTF_H
+#define __VASPRINTF_H
+
+#include <stdarg.h>
+#include <config.h>
+
+#ifndef HAVE_VASPRINTF
+int vasprintf(char **ret, const char *fmt, va_list ap);
+#endif
+
+#endif /* __VASPRINTF_H */