Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!hp4nl!philmds!nlgvax!hans From: hans@nlgvax.UUCP (Hans Zuidam) Newsgroups: comp.software-eng Subject: Re: Recursive #includes Summary: #ifndef FILE_H is good. Keywords: recursive includes, modularity Message-ID: <221@nlgvax.UUCP> Date: 26 Feb 89 17:18:08 GMT References: <570@marob.MASA.COM> Reply-To: hans@nlgvax.UUCP (Hans Zuidam) Organization: Philips Research Geldrop Lines: 41 Commodore uses the same scheme for their include files for the Amiga software and it is a blessing. This way I (the user) never have to deal with multiple includes. Commodore has extended the above a little: #ifndef EXEC_TASKS_H #define EXEC_TASKS_H #ifndef EXEC_NODES_H #include #endif !EXEC_NODES_H #ifndef EXEC_LISTS #include #endif !EXEC_LISTS ... Stuff here ... #endif !EXEC_TASKS_H The include files are distributed over several related directories ("exec", "graphics", "devices" and what not). Furthermore the header files include what they themselves need. This is as it should be. On BSD you reguarly have to include files that your program do not need but files included do need. See for example the files in "net". If you try to compile a file which only includes you will get a nice bunch of errors, and you will be left completely blank as to what to include also. Or said different: I have to figure out what someone already figured out before me (the BSD networking software does work ;-)). Include files should be as much self contained as possible. They are in many cases an interface between a pieces of code. A good test is that you should be able to take a single include file and compile it without errors. With respect to Makefile dependencies: use makedepend and you will not have troubles there. The method above even lets you build a dependency list by hand *quickly*. -- Hans Zuidam E-Mail: hans@pcg.philips.nl Philips Telecommunications and Data Systems, Tel: +31 40 892288 Project Centre Geldrop, Building XR Willem Alexanderlaan 7B, 5664 AN Geldrop The Netherlands