On 10 April 2011 00:09, River Tarnell <river.tarn...@wikimedia.de> wrote:
> -----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.

Hmm currently I'm using _vscprintf / vsprintf on Windows/MSVC inside
#ifdef _WIN32
and vasprintf Ubuntu/gcc inside #else

But my C-fu is to puny to figure out what #ifdefs to use to detect
what combination of C compiler and libc I'm compiling under.
Apparently it's important with snprintf since some implementations
return "an unspecified return value less than 1" with size=0.

I don't want to have to use autoconf or swtich to a gcc on Windows.

Andrew Dunbar (hippietrail)


>        - river.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (SunOS)
>
> iEYEARECAAYFAk2gaJ4ACgkQIXd7fCuc5vKziwCfTbDgK0nX32jK8iJcLWl278BK
> HNwAnRFW8/BhMUKS7zr6RRBcPlqCeWfj
> =31oq
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org)
> https://lists.wikimedia.org/mailman/listinfo/toolserver-l
> Posting guidelines for this list: 
> https://wiki.toolserver.org/view/Mailing_list_etiquette
>

_______________________________________________
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org)
https://lists.wikimedia.org/mailman/listinfo/toolserver-l
Posting guidelines for this list: 
https://wiki.toolserver.org/view/Mailing_list_etiquette

Reply via email to