Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Getting Started

Installing Chrono
Hello World!
Getting Boost.Chrono

Boost.Chrono is in the latest Boost release in the folder /boost/chrono. Documentation, tests and examples folder are at boost/libs/chrono/.

You can also access the latest (unstable?) state from the Boost trunk directories boost/chrono and libs/chrono. Just go to here and follow the instructions there for anonymous SVN access.

Where to install Boost.Chrono?

The simple way is to decompress (or checkout from SVN) the files in your BOOST_ROOT directory.

Building Boost.Chrono

Boost.Chrono can be configured as a header-only library defining BOOST_CHRONO_HEADER_ONLY. However Boost.Chrono depends on the non header-only library Boost.System, so that you will need to link with boost_system.

Boost.System has an undocumented feature (use of macro BOOST_ERROR_CODE_HEADER_ONLY) to make it header only.

If BOOST_CHRONO_HEADER_ONLY is not defined you need to compile it and build the library before use, for example using:

bjam libs/chrono/build
Requirements

In particular, Boost.Chrono depends on:

Boost.Config

for configuration purposes, ...

Boost.Exception

for throw_exception, ...

Boost.Integer

for cstdint conformance, ...

Boost.MPL

for MPL Assert and bool, logical ...

Boost.Operators

for operators, ...

Boost.Ratio

for ratio, milli, micro, ...

Boost.System

for error_code, ...

Boost.TypeTraits

for is_base, is_convertible, common_type, ...

Boost.Utility/EnableIf

for enable_if, ...

Building an Executable that Uses Boost.Chrono

In addition to link with the Boost.Chrono library you need also to link with the Boost.System library. If Boost.System is configured defining BOOST_ERROR_CODE_HEADER_ONLY you will no need to link with it as the dependent part is header only then.

Exception safety

All functions in the library are exception-neutral and provide strong guarantee of exception safety as long as the underlying parameters provide it.

Thread safety

All functions in the library are thread-unsafe except when noted explicitly.

As Boost.Chrono doesn't use mutable global variables the thread-safety analysis is limited to the access to each instance variable. It is not thread safe to use a function that modifies the access to a user variable if another can be reading or writing it.

Tested compilers

The implementation will eventually work with most C++03 conforming compilers. Currently I use to test with on:

Windows with

  • MSVC 10.0

MinGW with

  • GCC 4.5.0
  • GCC 4.5.0 -std=c++0x
  • GCC 4.5.2
  • GCC 4.5.2 -std=c++0x
  • GCC 4.6.0
  • GCC 4.6.0 -std=c++0x
  • GCC 4.8.0
  • GCC 4.8.0 -std=c++0x

Ubuntu with * GCC 4.4.6 * GCC 4.4.6 -std=c++0x * GCC 4.5.4 * GCC 4.5.4 -std=c++0x * GCC 4.6.1 * GCC 4.6.1 -std=c++0x * Intel 12.1.3 * Intel 12.1.3 -std=c++0x

OsX with

  • GCC 4.1.2
  • GCC 4.6.2
  • GCC 4.6.2 -std=c++0x
  • GCC 4.7.0
  • GCC 4.7.0 -std=c++0x
  • GCC 4.7.1
  • GCC 4.7.1 -std=c++0x
  • GCC 4.7.2
  • GCC 4.7.2 -std=c++0x
  • GCC 4.8.0
  • GCC 4.8.0 -std=c++0x
  • GCC 4.8.1
  • GCC 4.8.1 -std=c++0x
  • clang 3.1
  • clang 3.1 -std=c++0x -stdlib=libc++
  • clang 3.2
  • clang 3.2 -std=c++11 -stdlib=libc++

The committed code is tested with much more compilers. There are two compilers (VACPP and Borland) that don't provide the needed features. Other as Intel and Sun have some issues with i/o. While everything compiles and link correctly, there are some runtime issues I have not cached yet. See the regression tests for details.

[Note] Note

Please let us know how this works on other platforms/compilers.

[Note] Note

Please send any questions, comments and bug reports to boost <at> lists <dot> boost <dot> org.


PrevUpHomeNext