shared: fix nm_sprintf_buf() macro to allow plain string

Use non-portable gcc extension to allow for zero variadic
arguments so that you can pass a plain string as argument.
This commit is contained in:
Thomas Haller
2016-02-19 01:40:02 +01:00
parent 7197425137
commit 6d5e55870a

View File

@@ -429,7 +429,7 @@ nm_decode_version (guint version, guint *major, guint *minor, guint *micro) {
* It disallows a buffer size of sizeof(gpointer) to catch that. */ \ * It disallows a buffer size of sizeof(gpointer) to catch that. */ \
G_STATIC_ASSERT (G_N_ELEMENTS (buf) == sizeof (buf) && sizeof (buf) != sizeof (char *)); \ G_STATIC_ASSERT (G_N_ELEMENTS (buf) == sizeof (buf) && sizeof (buf) != sizeof (char *)); \
g_snprintf (_buf, sizeof (buf), \ g_snprintf (_buf, sizeof (buf), \
""format"", __VA_ARGS__); \ ""format"", ##__VA_ARGS__); \
_buf; \ _buf; \
}) })
@@ -440,7 +440,7 @@ nm_decode_version (guint version, guint *major, guint *minor, guint *micro) {
G_STATIC_ASSERT (sizeof (char[MAX ((n_elements), 1)]) == (n_elements)); \ G_STATIC_ASSERT (sizeof (char[MAX ((n_elements), 1)]) == (n_elements)); \
_buf = g_alloca (n_elements); \ _buf = g_alloca (n_elements); \
g_snprintf (_buf, n_elements, \ g_snprintf (_buf, n_elements, \
""format"", __VA_ARGS__); \ ""format"", ##__VA_ARGS__); \
_buf; \ _buf; \
}) })