Conditional inclusion

Walter Bright bright at Data-IO.COM
Tue Oct 24 11:25:34 AEST 1989


In article <14240 at well.UUCP> nagle at well.UUCP (John Nagle) writes:
<	#ifndef XXX
<	#define XXX
<	...content...
<	#endif
<This works, but on the second inclusion, the file still has to be read and
<parsed, at least by the level of processing that reads "#" statements.
<With widespread use of this technique within library files, some files may
<be read a large number of times, mostly to be ignored.  This slows compilation.

This problem has been made worse by ANSI C, which now requires that the
text in false conditionals be "tokenized". Tokenizing is a far slower
process than going into a special loop that screams past characters
until a preprocessor line is found ('\n' { whitespace } '#'). In fact, on
most CPUs once a line is determined to not be a preprocessor line, an
extremely fast scan for '\n' can be done. Tokenizing is at least an order
of magnitude slower.



More information about the Comp.std.c mailing list