Xref: utzoo comp.lang.c:16532 comp.software-eng:1142 Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ukma!rutgers!cmcl2!phri!marob!samperi From: samperi@marob.MASA.COM (Dominick Samperi) Newsgroups: comp.lang.c,comp.software-eng Subject: Recursive #includes Keywords: recursive includes, modularity Message-ID: <570@marob.MASA.COM> Date: 26 Feb 89 02:37:38 GMT Followup-To: comp.software-eng Organization: ESCC New York City Lines: 39 Are recursive #includes hazardous to your software's health? I'm working on a system where each header file has the form: : #ifndef H_FOO #define H_FOO defines, declarations, etc. #endif This scheme permits header files to be included two or more times, even recursively, where the second and subsequent includes of the same file will have no effect. (That is, a header file A can include another header file B, which in turn includes A, but since H_A will be defined when A is included the first time, the second include of A will have no effect, and the recursion will end.) Although this trick will avoid the common problems caused by including a header file more than once, I suspect that it will also encourage the inclusion of files that are not even needed (since there is no chance for multiple definitions, if there is some chance that the definitions may be needed, what the heck). Furthermore, permitting recursive includes may tend to smear the separation between modular components of the software system, and designing a correct makefile will be a mess. These problems, together with the discovery that some preprocessors consider any recursive include to be a fatal error, have motivated me to discontinue the use of this trick, and discontinue the use of recursive includes as well. Perhaps others could comment on this. -- Dominick Samperi -- ESCC samperi@marob.masa.com uunet!hombre!samperi