The cxxomfort library should hardly require some configuration, depending on the compiler and system you use. However right now only GCC >= 4.6 and MSVC 2008 are *officially* tested for. More information will be added here as more compilers are tested.

General configuration procedure

The key element to configure this library is to make sure that TR1 (for C++03 mode) is supported correctly and the headers work in a manner similar to how they work in C++11:

  1. The TR1 headers must be able to be #included directly - by name only (such as #include <array>). Make sure adequate support for TR1 is enabled and the TR1 path is added to the compiler/project's #include path.
  2. Add the cxxomfort/ path to your compiler/project's #include path.

If your compiler does NOT provide TR1:

(I'm looking at you, MSVC 2008 Express)

You might be able to get past it by installing a third party TR1, such as Boost's, provided it supports at least array, tuple and type_traits. Such configurations are not supported officially however.


Configuring GCC

To add the path to a compile command, use the -I or -isystem switches:

g++ [...options] -I /path/to/include/cxxomfort/ [...sources]

(The following information applies only to C++03 mode)

GCC incorporates the Tr1 headers (<array> etc) in the tr1/ subdirectory. Unfortunately, because of the way the include directives within are coded, it is not possible to have code compile by adding the tr1 directory to the #include path.

Since GCC considers Tr1 "not worth fixing", it is instead recommended to use an alternative Tr1 implementation such as Boost.Tr1.

If one still wishes to use GCC's native Tr1 one will need to create "forward-headers" that include the necessary TR1 headers and then add the forward-header directory to the compiler/project's #include path. One such set of forwarding headers can be seen in this Fossil repo (tr1_fwd). (TOBEDONE: merge with cxxomfort)

Patching headers note

Due to the way the TR1 headers are configured and the include directives written in GCC (see the bug linked at "Configuration"), code that includes the <list> or <unordered_{set,map}> headers might cause errors about ambiguous children namespaces (see this link).

There are two ways around this issue detailed in the following issue: (link pending):

  • patch stl_list.h to refer to the namespace by full name, or...
  • Make sure that code using cxxomfort #includes the list or unordered_x headers before cxxomfort/cxxomfort.hpp - note that base features (cxxomfort/base.hpp) are not affected.

Configuring with clang

Use the -I switch to add to the compiler path:

clang [...options] -I /path/to/include/cxxomfort/ [...sources]

For the most part this will be setup and work exactly as it does in GCC; however, it might be necessary to patch a couple of header files from the tr1/ implementation if using clang alongside GCC 4.6 or earlier (more specifically, to deal with the declarations of some of the new cmath functions). Patching the libraries so falls outside the scope of this document.

Configuring with MSVC

Use the -I switch to add to the compiler path:

cl.exe [...options] -I /path/to/include/cxxomfort/ [...sources]

(The following information applies only to MSVC 2008)

MSVC 9 (2008) Express does not ship with a tr1 implementation, thus lacks, among the most important features, a <type_traits> implementation. This is partly solved by cxxomfort providing its own type traits, but this should not be relied upon by client programs. cxxomfort code using features from <functional> will most likely fail to compile without an alternative TR1 implementation.

Some sources say the MSVC9 Feature Pack can be installed to provide a working tr1 implementation; however this can not be installed in 2008 Express and thus Feature Pack setup is not tested or coded for; if using Express, it is up to you to provide a working TR1 implementation via boost, stlport or similar (tests were run via a pared down version of Boost.Tr1).