Boost logo

Boost :

Subject: Re: [boost] ATTENTION: Library requirements..
From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2016-01-09 23:26:08


On Sat, Jan 9, 2016 at 5:01 PM, Soul Studios wrote:
> I would also like to see guidelines for the use of small custom macros in
> boost libraries.
[cut]
> I can't find anything in your documentation, so I just thought I'd ask if
> there are any definitive guidelines around the use of small macros in boost
> libraries.

If there are macros in your public headers that are defined but
always undefined, then it won't impact users of your library.

If the macros are not undefined:
1. Make sure they are documented so that users know about them
2. Make sure the macro namess are prefixed with the library name

For example, for Boost.Something, in boost/something/file.hpp:

    #ifndef BOOST_LIBRARY_SOMETHING_FILE_HPP
    #define BOOST_LIBRARY_SOMETHING_FILE_HPP
    // ...
    #if defined(__INTEL_COMPILER)
    #define BOOST_SOMETHING_USING_ICC
    #endif
    // ...
    #if !defined(BOOST_NO_CXX11_ALLOCATOR)
    #define SHOULD_USE_ALLOCATOR_TRAITS
    #endif
    // ...
    #undef SHOULD_USE_ALLOCATOR_TRAITS
    // ...
    #endif

Of course, include guard macros fall into the second category, but
it's fine if you do not document them. (And it wouldn't be a bad idea
for macros in the first category to also be prefixed with the library
name).

Glen


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