Programming Style

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Wed Apr 17 11:15:37 AEST 1991


In article <1991Apr16.154655.14204 at hellgate.utah.edu> u-beasth%peruvian.utah.edu at cs.utah.edu (Bryant Eastham) writes:
> When
> the standard says that system headers may be included multiple times then
> write code as though they can.

For code that you write once and use in-house, do whatever works.

For code that you distribute or plan to port to future systems, you
should never make an assumption like that. Chances are your code won't
compile on two different systems. Which is better, some work on your
part now to make your application portable, or thousands of hours of
work on the part of others in the future to do the job for you?

I fully support properly protected #include files. I even sent out a
simple tool recently---comp.sources.misc/volume17/quacko---which tests
that your .h file not only correctly reflects the symbols in your .o
file, but can be included both once and twice without preparation. But
I'm not going to pretend that vendors care about #include file quality,
and I'm not going to (intentionally) write code that includes system
headers twice.

---Dan



More information about the Comp.lang.c mailing list