On Thu, Aug 19, 2004 at 01:42:14PM +1000, Sisyphus wrote: > void wrap_printf(AV * arguments) { > /* Code to transfer the referred arguments to C's printf() function */ > } > > I don't know, off the top of my head, exactly what *that* "Code" looks > like either - though I'm confident I can work it out. > > A slight problem with this last rendition is that one will now have to > call wrap_printf() from perl as: > > wrap_printf(["%d\n%#o\n", $x, $y]); > > which is different to the usual printf() argument format - which would > be unfortunate, though tolerable.
I think that it's possible to partly work round this by prototyping your function (at the perl level), but in turn I don't think that Inline can do this; you'd need XS. But even that doesn't really solve the problem at perl level, as @a = (%d\n%#o\n", $x, $y); wrap_printf(@a); would work correctly with @a actually passed in as [EMAIL PROTECTED], but wrap_printf("%d\n%#o\n", $x, $y); wouldn't. (I think. Sorry, this is untested) And as the rest of the thread discusses, even this doesn't solve the problem of generating a va_arg list. Which I think can't be done portably (ie without cheating). Nicholas Clark