Re: A programming style question

From: David Luyer <luyer@dont-contact.us>
Date: Thu, 13 Jan 2000 10:56:41 +1100

DW wrote:
> On Wed, 12 Jan 2000, Yee Man Chan wrote:
>
> > Hi,
> >
> > I find that all .c files in the src directory of 2.2S5 or 2.3S1 only includes
> > squid.h. And squid.h includes protos.h, enums.h, etc. I am just curious why
> > squid choose to include in this way in favor of the old fashion: (arguably
> > more widely used) one .h for one .c, so u have put those #ifndef .... #endif
> > in each .h? Can anyone tell me the advantages and disadvantages of these two
> > styles?
>
> This was my doing.
>
> Previously, the .h files were confusing because some structures had
> cross references. After making changes, I was often required to
> re-order the list of .h files so that it would compile.
>
> I found it was much easier to manage by listing all enums and typedefs
> before structs and prototypes.

There is another advantage you didn't realise, or maybe did. Since squid is
left compiled with debugging, the executable size is massively reduced by the
single squid.h. gcc will basically share the debugging info if include files
are included in the same order, but if they aren't then it won't, since some
#defines etc being different due to the different order of the include files
may have influenced the included files.

For discussions on this see the wine-devel list archive, probably 6-12 months
ago.

David.

-- 
David Luyer                           . .           www.zipworld.net
Network Engineer                    .  zipworld         Zip World is
Phone: +61 2 9253 5755              .     .      proudly part of the
Fax:   +61 2 9247 5276                . .     Pacific Internet Group
Received on Wed Jan 12 2000 - 16:58:03 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:20 MST