A question on C programming style

Lars Wirzenius wirzenius at cc.helsinki.fi
Sun Apr 14 00:40:26 AEST 1991


In article <1991Apr12.103621.8907 at umiami.ir.miami.edu>, bxpfac at umiami.ir.miami.edu writes:
> How do the guru's on the net feel about the following two styles?

(Uh, more like a bandwith-waster, I'm afraid...)

> Style 1: (No nested includes - user responsible for proper order of includes).
> Style 2: (Nested inclusion [each header includes everything it needs
> included before it]).

I very much prefer style 1. Style 2 will very likely cause multiple
inclusions, which at best wastes time (the compiler has to process each
include every time), and at worst causes errors, since not all headers
can be included multiple times. The only exception is an include file,
whose only purpose is to include a set of headers that are needed in all
or most of the source files in a given project.

-- 
Lars Wirzenius    wirzenius at cc.helsinki.fi



More information about the Comp.lang.c mailing list