Boost logo

Boost :

Subject: [boost] [system][chrono] header-only libs
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-10-12 19:37:50


Hi,

after discussion with Ion about whether Boost.Interprocess could use Boost.Chrono and Boost.System he has found as major drawback that both are not header-only libs. I have implemented Boost.Chrono as a header only lib.

If the user wants Boost.Chrono be a header-only lib s/he needs to define the BOOST_CHRONO_INLINED macro. While this could be useful, there is a problem as Boost.Chrono depends on Boost.System that is not a header-only lib.

* I have added this on the configuration file

#ifdef BOOST_CHRONO_INLINED
#define BOOST_CHRONO_INLINE inline
#define BOOST_CHRONO_DECL
#else
#define BOOST_CHRONO_INLINE
// as before
#endif

* Copied all the .cpp files to the detail/inlined directory.
* Renamed the .cpp file by .hpp files
* Included in the old .cpp files the corresponding .hpp file in the detail/inlined directory

* I've replaced the prefix suffix as follows:

#ifndef BOOST_CHRONO_INLINED
#include <boost/config/abi_prefix.hpp> // must be the last #include
#endif
#ifndef BOOST_CHRONO_INLINED
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
#else
#include <boost/chrono/detail/inlined/file_name.hpp>
#endif

* prefixed the definitions of the function in the .cpp files by BOOST_CHRONO_INLINE

While doing this I have found a minor issue on Windows platform. I hve nedeed to sorrounded by () all the use of min and max functions on the test files to avoid the macros defined on the windows.h file. That means that a header-only lib could break user sources as it will include implicitly some platform files. Another drawback that I have no inspected yet could be the increase in size and compilation time of the user code.

Beman do you mind if I try to make your library configurable as header-only, so Ion could use Boost.System and Boost.Chrono and preserve Boost.Interprocess as a header-only lib?

Best,
Vicente

P.S. You can see the sandbox for the last modifications
_____________________
Vicente Juan Botet Escribá
http://viboes.blogspot.com/


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