[ccan] Can _GNU_SOURCE be conditional in TAP?
Rusty Russell
rusty at rustcorp.com.au
Tue Mar 31 23:14:48 EST 2009
On Tuesday 31 March 2009 18:15:20 Tim Post wrote:
> Hi Me,
>
> On Tue, 2009-03-31 at 15:41 +0800, Tim Post wrote:
>
> > What extensions to the glibc printf sub system are enabled with
> > _GNU_SOURCE? I think people would expect them in a replacement
> > implementation of asprintf() (turned on by _GNU_SOURCE), which might
> > entail a whole ccan printf module to replace it.
>
> Such extensions would also be assumed by printf(). I'm using a rather
> old libc, because upgrading at this point is going to be a major pain in
> the ass.
>
> I don't know for sure that there are any, but thought I'd toss that out.
In this case, we just want asprintf. The asprintf header would do something
like:
#ifdef HAVE_GNU_SOURCE
#define _GNU_SOURCE 1
#include <stdio.h>
#else
extern int asprintf(...
#endif
Of course this won't work if they've already included <stdio.h>. So I'd
be deeply tempted to implement different versions which return the ptr
directly (aprintf?).
Cheers,
Rusty.
More information about the ccan
mailing list