This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Creating a va_list dynamically?


"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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]