parsing the format string at compile time...
david richard cook
drcook at hubcap.clemson.edu
Wed Oct 11 21:50:53 AEST 1989
>From article <705 at nixbur.UUCP>, by jobrien at nixbur.UUCP (John O'Brien):
> printf call is a constant (which it is most of the time), the compiler
> should be able to parse the string at compile time, and turn the printf
> call into something like the series of Modula-2 calls, with a correspond-
> ing increase in efficiency. Do C compilers do this? Are there any prob-
> lems with doing this?
>
> Enquiring Minds Want to Know!
>
If C did allow this, it would not be C. The compiler knows
nothing about any functions, including I/O. Some new compilers may be
able to this, though I do not know of any, by using the #pragma
preprocesser directive to declare certain functions as builtin. The
use of #pragma is left up to the compiler implementation and not C.
If an ANSI C implementation does not understand what the #pragma
directive is trying to accomplish, it will simply ignore it.
More information about the Comp.lang.c
mailing list