duplicate instantiations
Michael Goffioul
michael.goffioul at gmail.com
Tue Jun 2 07:16:50 CDT 2009
On Tue, Jun 2, 2009 at 12:54 PM, Jaroslav Hajek <highegg at gmail.com> wrote:
> hi Michael,
>
> I noticed that as part of 9237:3c1762c7e787, you added lines like
> template class OCTAVE_API DiagArray2<Complex>::Proxy;
>
> to Array-*.cc. While this is accepted by GCC, it gets rejected by
> Intel C++, griping about duplicate instantiation.
> I've asked for advice on comp.lang.c++, but after a quick
> investigation it seems to me that Intel is right here. An explicit
> instantiation of a class instantiates all its non-template members,
> including member classes, which causes a duplicate explicit
> instantiation.
> I assume the OCTAVE_API decoration does not automatically apply to
> member classes? Is there a different way to do this with MSVC?
> I'm not really much fond about the whole DiagArray2::Proxy stuff, but
> I wouldn't like to remove it now. OTOH, I wouldn't like to keep code
> needed only for MSVC (and fooling other commercial compilers) which is
> actually incorrect C++.
The problem here is indeed the OCTAVE_API decoration, which does
not apply to member classes. So, even if MSVC instantiates all members
on DiageArray2<xxx> statement, including member classes, those do not
get exported, which is then a problem later on (undefined references).
I remember that I had to explicitely instantiate (and decorate) ::Proxy
classes, before the surrounding class, otherwise I also got a compilation
error due to duplicate specialization.
Unfortunately, at the moment I don't see any other solution.
If that's a problem, feel free to remove the offending statements, and I'll
maintain a patch MSVC just for myself.
Michael.
More information about the Octave-maintainers
mailing list