Boost logo

Boost :

From: Don Waugaman (dpw_at_[hidden])
Date: 2001-07-03 12:13:09

On Tue, Jul 03, 2001 at 12:50:06PM -0400, David Abrahams wrote:
> ----- Original Message -----
> From: "Jeff Paquette" <paquette_at_[hidden]>
> > Include guards can and are also used to prevent the header from being
> > reparsed (as suggested by Lakos). As such, it (IMHO) would be better if
> the
> > guard referenced the file name.
> >
> > I'd rather write:
> >
> > #if !defined(BOOST_XXX)
> > #include "boost/xxx"
> > #endif
> >
> > than
> >
> > #if !defined("68C2D2A0-6FD1-11d5-8F0C-00105AC8B6E1")
> > #include "boost/xxx"
> > #endif
> This practice is unreliable with most headers. For example, you can't do
> that with your system headers if you're writing portable code. Most standard
> and 3rd party libraries don't document their #include guard conventions, so
> you have to look inside the header to determine what guard they used -- and
> there's no guarantee they won't change it.
> We could of course establish such a convention with boost headers, but I am
> unconvinced of the benefits.
> Finally, many modern compilers have learned to recognize #include guards
> such that this functionality is automated and you get zero benefit from
> cluttering files with such checks.
> -Dave

Would there be something wrong with combining the two approaches?

#if !defined(BOOST_XXX_68C2D2A0_6FD1_11d5_8F0C_00105AC8B6E1)
#include "boost/xxx"

Low probability of collisions with a convention at pointing to the header
file name.

After a quick look at the coding standards, it seems to imply something
of this sort (the example preprocessor symbol is RECTANGLE_DWA050499_H_)
for the header for the class rectangle. A Boost-specific convention
could be to have the first two underscore-separated names be the name
of the file (uppercased, of course) - or perhaps have the file name
end with the characters _H_ in the preprocessor symbol, then have the
guid after that.

    - Don Waugaman (dpw_at_[hidden])    O-             _|_  Will pun
Web Page:            |   for food
In the Sonoran Desert, where we say: "It's a dry heat..."  |     <><
How do you know when it's time to tune your bagpipes?

Boost list run by bdawes at, gregod at, cpdaniel at, john at