|
Boost : |
Subject: [boost] config.hpp
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2008-10-08 03:38:02
I'm digging up a previous topic of mine :
http://article.gmane.org/gmane.comp.lib.boost.user/39236/match=config
Basically, is it possible to consolidate the boost/config headers so
they provide a macro usable in #ifdef and such so we can use Boost
comprehensive platform/compiler tests in library ? I know some are
already usable (like testing for BOOST_MSVC and such) but it lacks in
some area like platform.
My proposal is the following :
For platform, stdlib and compiler config flag, add a macro called
respectively :
BOOST_ACTIVE_PLATFORM_CONFIG
BOOST_ACTIVE_STDLIB_CONFIG
BOOST_ACTIVE_COMPILER_CONFIG
That contains a numeric value that identify the current chosen
configuration. For each type of configuration, files called
boost/config/platform_list.hpp,boost/config/stdlib_list.hpp
and boost/config/compiler_list.hpp are provided. Those files
contains the global list of possible active configuration and
give them proper usable symbol.
eg : platform_list.hpp
#ifndef __BOOST_CONFIG_PLATFORM_LIST_HPP__INCLUDED__
#define __BOOST_CONFIG_PLATFORM_LIST_HPP__INCLUDED__
#define BOOST_AIX_PLATFORM_CONFIG 100
#define BOOST_AMIGAOS_PLATFORM_CONFIG 101
/// and so on ...
#define BOOST_WIN32_PLATFORM_CONFIG 111
#define BOOST_UNKNOWN_PLATFORM_CONFIG 999
#endif
Then in win32.hpp, the following definition is provided :
#define BOOST_ACTIVE_PLATFORM_CONFIG BOOST_WIN32_PLATFORM_CONFIG
In user code, it can be checked like this :
#if (BOOST_ACTIVE_PLATFORM_CONFIG == BOOST_WIN32_PLATFORM_CONFIG)
// Some Win32 code
#else
// some other code for non-win32
#endif
Does this sound useful or am I overlooking some already existing boost
system that may already do this ?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk