Boost logo

Boost :

From: Jens Seidel (jensseidel_at_[hidden])
Date: 2007-12-14 17:05:12


On Fri, Dec 14, 2007 at 04:28:58PM -0000, John Maddock wrote:
> Jens Seidel wrote:
> >> PS2: I still miss an explanation from you why you use both internal
> >> and external inclusion guards:
> >> boost/math/complex/asinh.hpp contains:
> >>
> >> #ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED
> >> # include <boost/math/complex/details.hpp>
> >> #endif
> >>
> >> and boost/math/complex/details.hpp:
> >>
> >> #ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED
> >> #define BOOST_MATH_COMPLEX_DETAILS_INCLUDED
> >>
> >> Is this just old code or was it necessary because of the
> >> asinh/asin typo and you did so for other files as well?
> >>
> >> I suggest to remove all outer include guards (also in other files).
>
> Why? It makes no difference, except to improve performance for compilers
> that don't implement the include-guard detection trick that gcc uses.

Heh? What trick?

To ensure that an include file is not included twice one normally
defines a unique preprocessor macro at the beginning of the header file
and skips processing if it was previously defined.

Doesn't every Boost header does this? Do you consider using #define a
trick?

I just want to mention that
  #include <boost/math/complex/details.hpp>
is easier to read than
  #ifndef BOOST_MATH_COMPLEX_DETAILS_INCLUDED
  # include <boost/math/complex/details.hpp>
  #endif

It is also more secure because you increase the chance to make a typo in
the macro which could be hard to track down.
You're right that it could be a little bit faster but I have never seen
it somewhere (including Boost).

I was just curious ...

Jens


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk