[vtk-developers] Which compilers to use "extern template" with

David Gobbi david.gobbi at gmail.com
Thu Sep 1 13:47:15 EDT 2016


Thanks Berk, David.

I'll move forward with restricting VTK_USE_EXTERN_TEMPLATE to c++11
builds.  When I get around to modifying the existing AOS/SOA extern
template declarations, I'll ping Brad from the MR so that he can
double-check my work.

 - David


On Thu, Sep 1, 2016 at 11:41 AM, David Lonie <david.lonie at kitware.com>
wrote:

> On Thu, Sep 1, 2016 at 1:18 PM, David Gobbi <david.gobbi at gmail.com> wrote:
> > Hi David,
> >
> > You've been playing around with the "extern template" stuff for longer
> than
> > I have, so I'm wondering if you can share some experience.
>
> The extent of my understanding of this syntax is that means a
> particular template instantiation will be available at link time, and
> thus doesn't need to be compiled into the current translation unit.
>
> > It seems that restricting "extern template" to MSVC 2015 and up would
> reduce
> > or eliminate the need for "#pragma warning".  Would it be a bad thing if
> we
> > stopped using "extern template" with MSVC 2008, 2010, etc?  The reason
> that
> > I ask is that, as I expand the use of "extern template" to other parts of
> > VTK, I don't want to have to add "#pragma warning" every time.
>
> I think you're talking about the oddities of the MSVC-specific blocks
> in AOS/SOADataArrayTemplate, correct? The only practical difference I
> notice is that these are also explicitly exported. I'm not entirely
> sure the warning pragmas are still necessary on the versions of MSVC
> we support.
>
> Brad (cc'd) might know more, IIRC he originally wrote that block and
> tracked down the issues surrounding this.
>
> > For clang and gcc, I was only planning to use "extern template" when
> > -std=c++11 because otherwise clang generates a warning about this being a
> > "c++11 feature".
>
> This sounds reasonable, and might allow us to eliminate the test for
> _MINGW_, since I suspect those problems are actually an issue with
> older GCC, not necessarily MinGW itself.
>
> > On the other hand I could bite the bullet and also use "extern template"
> for
> > pre-c++11 builds, and insert pragmas into a whole bunch of source files
> > (probably 20 or so) to silence the warnings.
>
> I'd vote for limiting these to C++11 builds rather than adding pragmas
> all over, as long as we can get away with it. I don't think non-C++11
> builds would complain about them missing (with the possible exception
> of MSVC), and the worst case scenario is a slightly longer compile
> time as the templates are emitted in each translation unit (and
> subsequently stripped by the linker).
>
> Dave
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20160901/062b04a1/attachment.html>


More information about the vtk-developers mailing list