Boost logo

Boost :

Subject: Re: [boost] [testing] Add a tester with hidden visibility
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2015-05-07 12:32:13

On 7 May 2015 at 18:59, Andrey Semashev wrote:

> > I have no idea why you continue to insist on trying to second guess
> > the very well established pattern here. The design of the GCC
> > visibility support was chosen back in 2004 to correctly support all
> > combinations of GCC, MSVC and Mingw without any special casing,
> > trickery, or any macro work above the traditional preprocessor logic
> > used for MSVC.
> Well, it's not that simple. For example, if you dllexport a class template and
> explicitly instantiate it in a dll with a non-exported type as a template
> parameter, you will get what you want - an exported specialization. Hidden
> visibility, OTOH, is viral, so the instantiated template will silently become
> hidden in this case.
> Other than that, yes, it's rather similar to MSVC.

It is a bad idea to dllexport templates as it greatly increases the
chance of an ODR violation biting you in the ass (e.g. two internal
private types with the same name). Nor is it ever necessary, as
template implementation is always header only. Just leave templates,
or any header implemented code, alone. Let them be compiled into a
local implementation for every ELF object. Remove anything you really
need to have exactly a single implementation of into a non-templated
base class which is dllexported.


ned Productions Limited Consulting

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