Conditional inclusion
Peter da Silva
peter at ficc.uu.net
Wed Oct 25 03:27:17 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.
In practice, you can combine this with a second technique:
#ifndef FROB_H
#define FROB_H
#ifndef SYS_FOO_H
#include <sys/foo.h>
#endif
#ifndef SYS_BAR_H
#include <sys/bar.h>
#endif
...
#endif
This completely resolves the efficiency question.
--
Peter da Silva, *NIX support guy @ Ferranti International Controls Corporation.
Biz: peter at ficc.uu.net, +1 713 274 5180. Fun: peter at sugar.hackercorp.com. `-_-'
"That particular mistake will not be repeated. There are plenty of 'U`
mistakes left that have not yet been used." -- Andy Tanenbaum (ast at cs.vu.nl)
More information about the Comp.std.c
mailing list