Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2001-06-01 06:26:43

Vesa's config scheme is very timely: I've been contemplating integrating
the regex config options with config.hpp - some have already been merged,
but others haven't primarily to prevent config.hpp from becoming as
cluttered as regex_config.hpp. However, I believe that with a few small
tweaks we can make Vesa's scheme even better:

1) I believe it is vital to separate configuration options into 3 separate
and orthogonal categories: the compiler, the standard library, and the

Consider that gcc can be used on any of the following platforms:

unix (multiple versions)
Mac OS X

and with the following standard libraries:

Dinkumware (for Linux)
Object space library

Or that Solaris has a <stdint.h>, no matter whether the compiler is gcc,
Como or Sunpro,

and you should see what I mean. I admit that there is some tangling here,
but not so much as to make the scheme unworkable. I use a similar scheme
in the regex headers and it works very well: however it's all in a single
monolithic header, and that makes it very hard to get to grips with for
maintenance, as well as having all the drawbacks that Vesa highlights.

2) We really need a method to regression test the boost configuration - in
fact I think that this should come *before* changes to config.hpp are
committed. What I would like to see are a set of separate test files, one
for each feature, which will only compile if that feature is supported.
The feature can then be tested in both a "positive" and a "negative" sense:

Positive test: should not compile if the macro needs to be defined and is

#include <boost/config.hpp>
// include test for BOOST_MACRONAME
#include "macroname.cxx"

Negative test: Will compile only if the macro is defined when it need not

#include <boost/config.hpp>
// include test for BOOST_MACRONAME
#include "macroname.cxx"
#error this file should not compile

Clearly this involves a lot of test files; I do not believe that these
should be a part of the main boost regression tests results - after all the
average end user has no need of this information, and in any case these
tests should require running relatively infrequently (only when a compiler
changes, or a new macro is added). I'm also hoping that various boosters
have some of these tests as code snippets on their machines already (and
yes that is a hint!), but for those that aren't already available I don't
mind spending some time writing some of these - some help would be welcomed

3) The test files above can also serve as the basis for an autoconf (or
whatever) script if required. I realize that this proposal is not popular
around here, but it is often asked for - and most Unix heads expect it.
Whatever this would be left until the end. One option would be for
autoconf (or whatever) to generate headers that are separate from the main
boost headers, but which can be used as the basis for a new config (rather
like STLPort).

4) I would prefer to see a "tidier" directory structure than the one Vesa
has come up with (echoing Jens' comments), and in fact I believe this is
possible if we change include directories to defines, imagine that
config.hpp looks like this:

// define default config headers,
// these dispatch to the real config header automatically:
#define BOOST_COMPILER_CONFIG <boost/config/compiler.hpp>
#define BOOST_STDLIB_CONFIG <boost/config/stdlib.hpp>
#define BOOST_PLATFORM_CONFIG <boost/config/platform.hpp>

// include config headers:

// include platform tailoring
// this file serves as a basis for
// autoconf [optional], or for hand
// tailoring to the platform,
// Most (all?) of the options in here should
// be user settings (eg don't give me threading support
// even if it's available), rather than strictly required
// settings.
#include <boost/config/site.hpp>
// include post config options
// this includes things like BOOST_STATIC_CONSTANT
// and normalisation code (where one macro implies another).
#include <boost/config/suffix.hpp>

Now by default config.hpp will include the dispatching headers
<boost/config/compiler.hpp> etc, which will then dispatch to the actual
config, for example <boost/config/compiler/borland.hpp> if __BORLANDC__ is
defined. However if you want you could define BOOST_COMPILER_CONIG to
<myheader> and that's what boost will look for. I believe that this is
actually more versatile that the scheme originally proposed, as well as not
having a directory structure quite so deep. Note that once set up
<boost/config.hpp> should *never* *ever* change (that means removing
comments and revision history etc to the html documentation). The
dispatching headers <boost/config/compiler.hpp> etc would change quite
often to begin with, but eventually hardly at all. Likewise the individual
compiler/platform/library config files <boost/config/stdlib/visualcpp.hpp>,
<boost/config/platform/win32.hpp>, <boost/config/stdlib/stlport.hpp> would
change infrequently (compared to the current config.hpp) once correctly set
up. The key is that we don't know whether everything is set up correctly
until we have a test suite - I suspect that some regression tests currently
failing to compile are actually config issues.

- John Maddock

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