Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!fuug!news.funet.fi!hydra!cc.helsinki.fi!wirzenius From: wirzenius@cc.helsinki.fi (Lars Wirzenius) Newsgroups: comp.lang.c Subject: Re: A question on C programming style Message-ID: <1991Apr15.152954.5995@cc.helsinki.fi> Date: 15 Apr 91 15:29:53 GMT References: <1991Apr12.103621.8907@umiami.ir.miami.edu> <1991Apr13.144026.5969@cc.helsinki.fi> <189@bria.UUCP> Organization: University of Helsinki Lines: 27 In article <189@bria.UUCP>, mike@bria.UUCP (Michael Stefanik) writes: > In an article, wirzenius@cc.helsinki.fi (Lars Wirzenius) writes: > | [ ... that I don't prefer nested inclusions -- lw ] > > Actually, if the include files are written correctly, very *little* time > is wasted and no errors are produced. It's a simple matter of wrapping > the include file in: > [ #ifndef SYM / #define SYM / ... / #endif ] Very much time can be wasted, if the compiler has to process, say, stdio.h (or another large header) multiple times. I can easily find several of my own programs, for which nested includes like this could cause some headers to be included about 10 or 15 times. Of course, if you're the only user on a 100 GIPS computer, that doesn't really affect compile times, but on my humble PC the time escalates very quickly. Furthermore, not all system headers are protected by the #ifndef/#define construction, and not everybody can change them, so the possibility for errors due to multiple inclusion will always be there, if the program is ever going to be ported. > Personally, I have found that nested includes are both convenient, and > make a great deal of sense. I agree, in theory, but I have great reservations in practice. -- Lars Wirzenius wirzenius@cc.helsinki.fi