This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/41005] [C++0x] Unable to link fstream open and ctor with std::string argument.



------- Comment #6 from jwakely dot gcc at gmail dot com  2009-08-10 20:05 -------
(In reply to comment #5)
> Instead of instantiating that code in every object a single explicit
> instantiation is provided in libstdc++.so, that's the purpose of
> src/fstream-inst.cc

... but in this case it fails to provide an explicit instantiation of the new
C++0x members because src/fstream-inst.cc is not compiled with -std=c++0x or
-std=gnu++0x

So the library tells the compiler not to instantiate the templates in your
code, promising to provide explicit instantiations, and then fails to provide
the explicit instantiations. So the workaround I gave in comment #3 provides
them in your program.  Another workaround would be to compile with
-D_GLIBCXX_EXTERN_TEMPLATE=0, which disables the extern template feature,
causing the compiler to implicitly instantiate the templates in every file that
needs them, and then rely on the linker to merge the duplicate definitions.

But the right fix is just to ensure src/fstream-inst.cc is compiled in C++0x
mode, so that the instantiations are present in libstdc++.so and you don't need
any workaround.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41005


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]