Creating a va_list dynamically?
Bruce Korb
bkorb@sco.COM
Mon Oct 9 12:01:00 GMT 2000
"Kaveh R. Ghazi" wrote:
>
> Is it possible to dynamically and portably create a va_list?
>
> I'm trying to see if I can easily teach gcc to optimize e.g.
>
> > fprintf("%d %s", 5, "hello") -> fputs("5 hello")
>
> What I'd like to do is, at compile time, take the tree structures
> representing 5 and "hello" and dynamically create a va_list out of
> them. Then I'd pass the format arg and the va_list to vasprintf() and
> emit a call to fputs with the resulting string.
>
> (If I can't use something like vasprintf, I'd have to rewrite a
> complete *printf parser. Bleah.)
I went round and round on this one a couple of years ago.
The upshot: You cannot get there from here (leastwise,
not portably). The consequence: Gary V. Vaughan was
extremely generous with his time and got motivated enough
to write the snprintfv library.
You can read about all the motivations here:
http://autogen.sourceforge.net/doc/autogen_7.html#SEC212
His official distribution directory:
http://www.oranda.demon.co.uk/dist/
But I think he keeps my CVS archive on SourceForge up to date, too:
cvs.AutoGen.sourceforge.net:/cvsroot/AutoGen/autogen/snprintfv
> Any info would be appreciated.
:-)
More information about the Gcc
mailing list