[Toolserver-l] Alternative C function to vasprintf() on Toolserver

River Tarnell river.tarnell at wikimedia.de
Sat Apr 9 14:09:34 UTC 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew Dunbar:
> I've got a little program to index dump files that supports Windows
> and Linux but it doesn't compile on the Toolserver with either cc or
> gcc due to the lack of the function vasprintf(). It's a GNU extension
> so I'm surprised it didn't work even with gcc.
 
> Why doesn't the Toolserver gcc have it, and does anybody know of a workaround?

*printf() is not part of the compiler, but the C library (libc); GNU 
glibc (used on Linux) provides it, while Solaris doesn't.  There's been 
some discussion about it, but there are several incompatible asprintf() 
interfaces around and it's not clear which one should be implemented.

Someone else already provided a version using snprintf, but you could 
also use g_vasprintf() from glib, or the version from gettext's 
libintl.h (which means you need to include <libintl.h> and link against 
- -lasprintf, both of which live in /opt/ts/gettext).  I personally find 
the snprintf solution the best and this is what I use in my own code.

	- river.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (SunOS)

iEYEARECAAYFAk2gaJ4ACgkQIXd7fCuc5vKziwCfTbDgK0nX32jK8iJcLWl278BK
HNwAnRFW8/BhMUKS7zr6RRBcPlqCeWfj
=31oq
-----END PGP SIGNATURE-----



More information about the Toolserver-l mailing list