site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com So class A { virtual void foo (); }; template <typename T> class B : public A { }; template <typename T> void blah (A * obj) { B<T> * bobj = std::dynamic_cast <B<T> * >(obj); if (!bobj) { //fails even if B<T>'s instance is loaded... } } That's it precisely. The explicit instantiations of B<T> are implemented as "dylibs" or some other dynamically loadable module of sorts. Not necessarily explicit instantiations... I'm not sure this is a real bug. Do you at least declare the explicit instantiation to exist in a common header file? Templates are a compile time construct of the C++ language. There's no easy way I know around this. The compilation unit pretty much has to have the definition for any of the instantiations you might use [due to the lack of "export" keyword support in gcc, but even then... you still need to access the source] That's it in a nutshell :) Thanks again for your help - it's proving very useful to me! Hugh Hoover Enumclaw Software _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On May 11, 2005, at 07:51, David Leimbach wrote: No - but when I attempt that, I get multiply-defined symbol errors. (with -fno-implicit-templates)
From further poking around, I find that the Itanium ABI spec, which is referenced from the Linux Base Spec for C++, which is a current attempt to standardize these things, explicitly says type_info's may be compared by pointer (canonical comparison not apparently required). In addition, in the gcc4 release notes from Apple, I find:
"GCC 4.0 supports full coalescing both within and across dylibs. If a template instantiation has external visibility then all copies of it, in all dylibs, will be merged into a single copy. If you want to ensure that a template instantiation in a dylib is not merged with template instantiations in any other dylib, use the visibility attribute to give the template hidden visibility." That says to ME that I should be getting an automatic coalescing of the type_info across the dylibs, but it's certainly NOT happening for me. Of course, they were talking about static members rather than type_info, but they're really the same thing. I do NOT have the new "hide everything" flags turned on. So - I'm more confused than ever - at least with respect to a workaround / solution. This email sent to site_archiver@lists.apple.com