Boost logo

Boost :

Subject: Re: [boost] [Boost.DLL] Formal Review request
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2014-10-04 07:24:23


On 4 Oct 2014 at 12:41, Andrey Semashev wrote:

> > > I think any such technique is non-portable since there is no portable way
> > > to obtain mangled name of a function in compile time.
> >
> > Who cares.
>
> I do, obviously.

The library abstracts a whole ton of non-portable stuff around DLLs.
Mangling is just another one of those.

> > All the major compilers do provide this, and a large
> > number of the minor ones. When myself and Antony surveyed the
> > situation during TypeIndex we were pleasantly surprised at just how
> > widespread support is for some magic macro which expands to the
> > mangled form of the enclosing function. Mangling schemes have also
> > basically reduced to just two kinds in recent compilers, with the
> > Microsoft mangling scheme considerably the harder to parse. Mangling
> > schemes are also very stable over time. That makes this proposal
> > tractable.
>
> We had a similar discussion already. IMO, the library in its core should not
> rely on compiler specific features and should be implementable in pure C++ and
> standard APIs. This ensures its portability. It doesn't matter how many
> compilers implement the extension because there will always be the one that
> doesn't.

Andrey, please list here three C++ compilers which had at least one
version release in the past five years which doesn't provide a magic
macro expanding out to the mangling of the enclosing function.

> In any case, I don't think that mangled names are useful for other reasons I
> mentioned.

With such support, the following:

    plugin = dll::import_variable_alias<my_plugin_api>(
        lib_path / "my_plugin_sum",
        "plugin",
        dll::load_mode::append_decorations
    );

can become:

    BOOST_DLL_IMPORT(
        lib_path / "my_plugin_sum",
        BOOST_DLL_AUTO_ALIAS(my_namespace::plugin), // import a
variable
        BOOST_DLL_AUTO_ALIAS(my_namespace::function), // import a
function
        BOOST_DLL_AUTO_ALIAS(my_namespace::object), // import a class
implementation
        ...
    )

For those very few compilers without sufficient support, I am sure a
BOOST_DLL_EXPLICIT_ALIAS macro could let you manually specify the
mangling for some imported symbol. This would be useful in any case
for MSVC to inspect Mingw binaries or vice versa.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



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