From: Douglas Gregor (dgregor_at_[hidden])
Date: 2006-09-27 11:43:20
> Doug Gregor wrote:
> I have implemented the printf example. I had a name clash with the
> printf in the system, and renamed the local one printff.
Ugh, okay. It seems that C++ should prefer the non-varargs "printf(const
char*)" over the system's "printf(const char*, ...)".
> The return in the recursion had to be modified:
> /*return*/ printf(++s, args...);
Change that "printf" to "printff" and everything works as expected. What's
happening here is that you're calling the system's "printf" with every
argument after the first. And since that "printf" returns an int (not
void), the "return" won't parse.
> When I added this example:
> const char* more = "have nothing to do with the case %s %s\n";
> printff(more, "tra la");
> the output is
> have nothing to do with the case tra la tra la
> instead of an exception for an extra format.
Once I change that "printf" to "printff" into the "return printf(" line,
it raises the exception as expected.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk