On Sunday, 4 January 2015 00:58:41 CEST, Thomas Lübking wrote:
You may add as many
template class Template<int>;
as ever you like and wherever you want - clang won't compile,
while gcc is happy with the one implementation in class.cpp and
no explicit instatiation at all. (Notice that multiple explicit
instatiations are ill-formatted and both compilers will complain
about that ;-)
If I just use the source that GCC is happy with and add this to the
class.cpp, clang compiles it fine:
template class Template<int>;
I do not need to use your #define i I insert this explicit template
instantiation info class.cpp. The key is to use this explicit template
instantiation at the place where the "missing" class method is actually
defined.
$ clang --version
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
I also get (a similar) behavior by feeding GCC the -fno-implicit-templates
command line switch which makes it behave "almost line clang". Some more
bits are at [1].
Therefore I think that https://gerrit.vesnicky.cesnet.cz/r/300 is right.
Cheers,
Jan
[1] https://gcc.gnu.org/onlinedocs/gcc/Template-Instantiation.html
--
Trojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/