From 1bc8b0ad4ee4e500fd8cda2864845553b85986f8 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Thu, 13 Feb 2003 21:39:03 +0000 Subject: [PATCH] c++config (_GLIBCPP_EXTERN_TEMPLATE): Define. 2003-02-13 Benjamin Kosnik * include/bits/c++config (_GLIBCPP_EXTERN_TEMPLATE): Define. * include/bits/basic_ios.tcc: Guard use of extern template. * include/std/std_iomanip.h: Same. * include/bits/streambuf.tcc: Same. * include/bits/stl_alloc.h: Same. * include/bits/locale_facets.tcc: Same. * include/bits/ostream.tcc: Same. * include/bits/istream.tcc: Same. * include/bits/fstream.tcc: Same. * include/bits/basic_string.tcc: Same. From-SVN: r62865 --- libstdc++-v3/ChangeLog | 13 +++++++++++++ libstdc++-v3/include/bits/basic_ios.tcc | 4 +++- libstdc++-v3/include/bits/basic_string.tcc | 4 +++- libstdc++-v3/include/bits/c++config | 16 +++++++++++++--- libstdc++-v3/include/bits/fstream.tcc | 2 ++ libstdc++-v3/include/bits/istream.tcc | 4 +++- libstdc++-v3/include/bits/locale_facets.tcc | 2 ++ libstdc++-v3/include/bits/ostream.tcc | 2 ++ libstdc++-v3/include/bits/stl_alloc.h | 2 ++ libstdc++-v3/include/bits/streambuf.tcc | 4 +++- libstdc++-v3/include/std/std_iomanip.h | 5 ++++- 11 files changed, 50 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7cb7769ea69..8901a98b569 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,16 @@ +2003-02-13 Benjamin Kosnik + + * include/bits/c++config (_GLIBCPP_EXTERN_TEMPLATE): Define. + * include/bits/basic_ios.tcc: Guard use of extern template. + * include/std/std_iomanip.h: Same. + * include/bits/streambuf.tcc: Same. + * include/bits/stl_alloc.h: Same. + * include/bits/locale_facets.tcc: Same. + * include/bits/ostream.tcc: Same. + * include/bits/istream.tcc: Same. + * include/bits/fstream.tcc: Same. + * include/bits/basic_string.tcc: Same. + 2003-02-13 Paolo Carlini * include/bits/ostream.tcc (sentry::sentry): Improve diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc index 7ee8015e29f..876281ae303 100644 --- a/libstdc++-v3/include/bits/basic_ios.tcc +++ b/libstdc++-v3/include/bits/basic_ios.tcc @@ -1,6 +1,6 @@ // basic_ios locale and locale-related member functions -*- C++ -*- -// Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -186,11 +186,13 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template class basic_ios; #ifdef _GLIBCPP_USE_WCHAR_T extern template class basic_ios; #endif +#endif } // namespace std #endif diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 3810ae1cd8b..f3cb93c31b6 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -1,6 +1,6 @@ // Components for manipulating sequences of characters -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -933,6 +933,7 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template class basic_string; extern template basic_istream& @@ -962,6 +963,7 @@ namespace std basic_istream& getline(basic_istream&, wstring&); #endif +#endif } // namespace std #endif diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 00983ac10af..ba8c4f980c6 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -1,6 +1,7 @@ // Predefined symbols and macros -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -36,8 +37,7 @@ // The current version of the C++ library in compressed ISO date format. #define __GLIBCPP__ 20030213 -// This is necessary until GCC supports separate template -// compilation. +// This is necessary until GCC supports separate template compilation. #define _GLIBCPP_NO_TEMPLATE_EXPORT 1 // This is a hack around not having either pre-compiled headers or @@ -49,6 +49,16 @@ // by the compiler, but instead instantiated into the library binary. #define _GLIBCPP_FULLY_COMPLIANT_HEADERS 1 +// Allow use of the GNU syntax extension, "extern template." This +// extension is fully documented in the g++ manual, but in a nutshell, +// it inhibits all implicit instantiations and is used throughout the +// library to avoid multiple weak definitions for required types that +// are already explicitly instantiated in the library binary. This +// substantially reduces the binary size of resulting executables. +#ifndef _GLIBCPP_EXTERN_TEMPLATE +#define _GLIBCPP_EXTERN_TEMPLATE 1 +#endif + // To enable older, ARM-style iostreams and other anachronisms use this. //#define _GLIBCPP_DEPRECATED 1 diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index 8f156040fe0..2c591c389a2 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -505,6 +505,7 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template class basic_filebuf; extern template class basic_ifstream; extern template class basic_ofstream; @@ -516,6 +517,7 @@ namespace std extern template class basic_ofstream; extern template class basic_fstream; #endif +#endif } // namespace std #endif diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index ea8573665ef..e0ae5ad8507 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -1,6 +1,6 @@ // istream classes -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -1189,6 +1189,7 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template class basic_istream; extern template istream& ws(istream&); extern template istream& operator>>(istream&, char&); @@ -1204,4 +1205,5 @@ namespace std extern template wistream& operator>>(wistream&, wchar_t&); extern template wistream& operator>>(wistream&, wchar_t*); #endif +#endif } // namespace std diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index c8eaa2e5b15..ffb97ea0c9c 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -2219,6 +2219,7 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template class moneypunct; extern template class moneypunct; extern template class moneypunct_byname; @@ -2472,6 +2473,7 @@ namespace std bool has_facet >(const locale&); #endif +#endif } // namespace std #endif diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc index 847f00b9be4..a60dd720739 100644 --- a/libstdc++-v3/include/bits/ostream.tcc +++ b/libstdc++-v3/include/bits/ostream.tcc @@ -701,6 +701,7 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template class basic_ostream; extern template ostream& endl(ostream&); extern template ostream& ends(ostream&); @@ -722,4 +723,5 @@ namespace std extern template wostream& operator<<(wostream&, const wchar_t*); extern template wostream& operator<<(wostream&, const char*); #endif +#endif } // namespace std diff --git a/libstdc++-v3/include/bits/stl_alloc.h b/libstdc++-v3/include/bits/stl_alloc.h index a40f7c1feae..96b51d18981 100644 --- a/libstdc++-v3/include/bits/stl_alloc.h +++ b/libstdc++-v3/include/bits/stl_alloc.h @@ -898,9 +898,11 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template class allocator; extern template class allocator; extern template class __pool_alloc; +#endif } // namespace std #endif diff --git a/libstdc++-v3/include/bits/streambuf.tcc b/libstdc++-v3/include/bits/streambuf.tcc index 44ba1d9d575..e721f25ed91 100644 --- a/libstdc++-v3/include/bits/streambuf.tcc +++ b/libstdc++-v3/include/bits/streambuf.tcc @@ -1,6 +1,6 @@ // Stream buffer classes -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -245,6 +245,7 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template class basic_streambuf; extern template streamsize @@ -258,6 +259,7 @@ namespace std __copy_streambufs(basic_ios&, basic_streambuf*, basic_streambuf*); #endif +#endif } // namespace std #endif diff --git a/libstdc++-v3/include/std/std_iomanip.h b/libstdc++-v3/include/std/std_iomanip.h index 26756a8041c..490d5ac1cfb 100644 --- a/libstdc++-v3/include/std/std_iomanip.h +++ b/libstdc++-v3/include/std/std_iomanip.h @@ -1,6 +1,7 @@ // Standard stream manipulators -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -265,6 +266,7 @@ namespace std // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template ostream& operator<<(ostream&, _Setfill); extern template ostream& operator<<(ostream&, _Setiosflags); extern template ostream& operator<<(ostream&, _Resetiosflags); @@ -292,6 +294,7 @@ namespace std extern template wistream& operator>>(wistream&, _Setprecision); extern template wistream& operator>>(wistream&, _Setw); #endif +#endif } // namespace std #endif -- 2.30.2