Creating a va_list dynamically?
Kevin Handy
kth@srv.net
Tue Oct 10 07:37: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")
Shouldn't there be a channel in these two functions?
> 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.
What about the cases where there is a mix of constants and
variables?
printf("%d %s %s\n", i, "Hello", "World")
could be simplified to
printf("%d Hello World\n", i);
but I don't know how much gain this type of optimization would be.
> (If I can't use something like vasprintf, I'd have to rewrite a
> complete *printf parser. Bleah.)
>
> Any info would be appreciated.
More information about the Gcc
mailing list