Re: confoig.h squid.h design

From: Alex Rousskov <rousskov@dont-contact.us>
Date: Sun, 27 Apr 2008 19:18:46 -0600

On Mon, 2008-04-28 at 11:17 +1200, Amos Jeffries wrote:
> > 1) config.h includes the autogenerated configuration file and does
> > virtually nothing else
> >
> > 2) squid.h includes config.h and does virtually nothing else.
> >
>
> Right. To be blunt and as simple as possible.
>
> Where does "squid_types.h" get included when every file in squid needs
> "uint32_t" ??

squid.h

and only if every source file in squid really needs it.

> THEN, where does "squid_mswin.h" get included for the same type
> definition in windows?

squid_types.h

because the code should be platform-independent to the extent possible
and should not care which platform it is being compiled on. OS-specific
hacks should be pushed as deep down as possible so that almost nobody
has to care about them.

> (NP: mswin (rightly!) setups more than types...)

Not sure what you mean, but we should have one .h file per type (or
"concept" or related group of types).

> Methinks squid_mswin.h goes in config.h and squid_types.h goes in
> squid_mswin.h (and other OS-specifics)

I think that would be wrong (but not a big deal). Universal type or
concept trumps OS-specific hacks. The main code that needs that
universal type should include the corresponding "universal" header (like
squid_types.h). That header may include OS-specific hacks as needed.

> > 3) any other .h file must be self-contained but may assume that squid.h
> > was included before that .h file.
>
> That 'but' is one thing we are trying to do away with. It's presence in
> FreeBSD and other sources has been a headache more than once for Squid.

I do not know what problems you are referring to, but I am not really
against removing the "but":

3) any other .h file must be self-contained.

This means that pretty much every file other than squid.h and config.h
will start with #include "squid.h" and most .cc files will include it
dozens of times, but it will work. You can make an exception for
compat/bits/ if you need them.

> > 4) any .cc file must include squid.h first.
>
> Okay.

HTH,

Alex.
Received on Mon Apr 28 2008 - 01:19:54 MDT

This archive was generated by hypermail 2.2.0 : Wed Apr 30 2008 - 12:00:07 MDT