Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!laidbak!daveb From: daveb@laidbak.UUCP (Dave Burton) Newsgroups: comp.lang.c Subject: Re: Making re-#includes harmless--a simple solution? Message-ID: <1281@laidbak.UUCP> Date: 13 Dec 87 05:44:31 GMT References: <2000@bloom-beacon.MIT.EDU> <1011@woton.UUCP> Reply-To: daveb@laidbak.UUCP (Dave Burton) Organization: is pretty bad/My method of Lines: 34 In article <1011@woton.UUCP> riddle@woton.UUCP (Prentiss Riddle ) writes: >newman@athena.mit.edu (Ron Newman) writes: >> Why not change the semantics of "#include" to be: "if, while >> processing the current .c source file, I have already included this >> file once, then don't include it again"? > >But sometimes you *want* to #include a file multiple times. ... ... I missed the first part of this exchange, so pardon me if I'm out-of-context. Why change the semantics of #include anyway? Using the following technique, you can make #include behave in both ways: #ifndef HEADER_H #define HEADER_H 1.0 /* version number, or nothing */ #define X #define Y #define Z #endif /* HEADER_H */ By enclosing the entire header file within the #ifndef/#endif pair (or just the critical portion), the header may be included several times without problem. -- --------------------"Well, it looked good when I wrote it"--------------------- Verbal: Dave Burton Net: ...!ihnp4!laidbak!daveb V-MAIL: (312) 505-9100 x325 USSnail: 1901 N. Naper Blvd. #includeNaperville, IL 60540