Under no circumstances I can think of.
If for some reason you want to be able to put an entire program on
one line (f'rexample, wanting a program to print its own source code
without having embedded backslashes to worry about escaping in the
output, as was discussed here not long ago), you'd need some way to
avoid preprocessor directives.
Whether or not this is a good reason is subject to debate. I can't
think of any other reasons that could claim to be good ones.
Furthermore supplying only the
prototype of printf might not be sufficient to make things work (think
about stdout).
The code that calls printf need not know anything about stdout; the
implementation of printf (in the runtime library) needs to know where to
put its output, but as long as the calling code calls it correctly (which
in the case of printf means having a correct prototype in scope[1][2]
and matching the arguments to the format string), the implementation is
required to make it work with no further requirements on the calling code.
dave
[1] This is best done by using "#include <stdio.h>" (you'll get no
argument about the "best" here), but "int printf(const char *,...);"
(in C89) is also perfectly valid.
[2] The requirement to have a prototype in scope is a result of printf
being a variadic function. In general, you can call a non-variadic
function whose arguments aren't subject to promotion without a
prototype[3], though there's no excuse for actually doing so.
[3] Question for the language lawyers: Is this legal? (There's no
argument that it's Evil, but that's not the same question.)
/*Not a prototype, but makes sure we have the correct return type*/
void *malloc();
/*size_t is assumed to not be subject to the usual promotions.
(Is this guaranteed?)
Note that we use sizeof to get a size_t without actually having
the implementation's definition in scope.
*/
struct foo *foo_ptr=malloc(sizeof *foo);
--
Dave Vandervies (e-mail address removed)
How neat do I have to be with my garbage?
That depends. How much do you want your programs to smell?
--Al Morgan and Richard Heathfield in comp.lang.c