Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-12-27 13:18:56

John Maddock wrote:

> The header auto_link.hpp has internal guards, so that it only emits
> the necessary #pragma if the compiler actually supports it, otherwise
> nothing happens except that the auto-link macros you defined will get
> #undef'ed.
> Even if these guards weren't present there will still be no errors,
> just a warning about an unrecognised #pragma.

While we're on this subject, I'd like to know what you think about adding a
no-name-mangling option to auto link. I would use it as follows:

The Iostreams library contains several components which depend the external
libraries zlib and libbzip2. I'd like to allow users to choose whether to build
these libraries with bjam, in which case I'll use the current auto-linking
mechanizm with the runtime library options encoded in the library name, or to
link to pre-built versions of the library, in which case I'll use pragma comment
(where available) together with the name of the external library file, passed as
a preprocessor define.

Currently I have code which looks like this (borrowed from auto_link.hpp):

    #if defined(BOOST_BZIP2_BINARY)
    # if defined(BOOST_MSVC) || \
         defined(__BORLANDC__) || \
         (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) || \
         (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) \
    # pragma comment(lib, BOOST_STRINGIZE(BOOST_BZIP2_BINARY))
    # endif

I'd rather do something like this:

    #if defined(BOOST_BZIP2_BINARY)
    # include <boost/config/auto_link.hpp>

That way I won't have to keep repeating the guard for the compilers which
support pragma comment. Another option would be to add a macro
HAS_PRAGMA_COMMENT, but this is not as general, since a compiler could
conceivably support auto linking in some other manner.


Boost list run by bdawes at, gregod at, cpdaniel at, john at