📄 reno.texi
字号:
\input texinfo @c -*- Texinfo -*-@setfilename reno-1.info@ifinfo@formatSTART-INFO-DIR-ENTRY* Reno 1: (reno-1). The GNU C++ Renovation Project, Phase 1.END-INFO-DIR-ENTRY@end format@end ifinfo@ifinfoCopyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc.Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.@ignorePermission is granted to process this file through TeX and print theresults, provided the printed document carries a copying permissionnotice identical to this one except for the removal of this paragraph(this paragraph not being relevant to the printed manual).@end ignorePermission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided also thatthe entire resulting derived work is distributed under the terms of apermission notice identical to this one.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions.@end ifinfo@setchapternewpage odd@settitle GNU C++ Renovation Project@c @smallbook@titlepage@finalout@title GNU C++ Renovation Project@subtitle Phase 1.3@author Brendan Kehoe, Jason Merrill,@author Mike Stump, Michael Tiemann@pageEdited March, 1994 by Roland Pesch (@code{pesch@@cygnus.com})@vskip 0pt plus 1filllCopyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc.Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.@ignorePermission is granted to process this file through Tex and print theresults, provided the printed document carries copying permissionnotice identical to this one except for the removal of this paragraph(this paragraph not being relevant to the printed manual).@end ignorePermission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided also thatthe entire resulting derived work is distributed under the terms of apermission notice identical to this one.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions.@end titlepage@ifinfo@node Top@top @sc{gnu} C++ Renovation ProjectThis file describes the goals of the @sc{gnu} C++ Renovation Project,and its accomplishments to date (as of Phase 1.3).It also discusses the remaining divergences from @sc{gnu} C++, and how thename encoding in @sc{gnu} C++ differs from the sample encoding in@cite{The Annotated C++ Reference Manual}.@c This is not a good place to introduce the acronym ARM because it's@c info-only. @menu* Introduction:: What is the GNU C++ Renovation Project?* Changes:: Summary of changes since previous GNU C++ releases.* Plans:: Plans for Reno-2.* Templates:: The template implementation.* ANSI:: GNU C++ conformance to ANSI C++.* Encoding:: Name encoding in GNU C++.@end menu@end ifinfo@node Introduction@chapter IntroductionAs you may remember, @sc{gnu} C++ was the first native-code C++compiler available under Unix (December 1987). In November 1988, it wasjudged superior to the AT&T compiler in a Unix World review. In 1990 itwon a Sun Observer ``Best-Of'' award. But now, with new requirementscoming out of the @sc{ansi} C++ committee and a growing backlog of bugs, it'sclear that @sc{gnu} C++ needs an overhaul.The C++ language has been under development since 1982. It hasevolved significantly since its original incarnation (C with Classes),addressing many commercial needs and incorporating many lessonslearned as more and more people started using ``object-oriented''programming techniques. In 1989, the first X3J16 committee meetingwas held in Washington DC; in the interest of users, C++ was going tobe standardized.As C++ has become more popular, more demands have been placed on itscompilers. Some compilers are up to the demands, others are not.@sc{gnu} C++ was used to prototype several features which have sincebeen incorporated into the standard, most notably exception handling.While @sc{gnu} C++ has been an excellent experimental vehicle, it didnot have the resources that AT&T, Borland, or Microsoft have at theirdisposal.We believe that @sc{gnu} C++ is an important compiler, providing users withmany of the features that have made @sc{gnu} C so popular: fast compilation,good error messages, innovative features, and full sources that may befreely redistributed. The purpose of this overhaul, dubbed the @var{@sc{gnu}C++ Renovation Project}, is to take advantage of the functionality that@sc{gnu} C++ offers today, to strengthen its base technology, and put it in aposition to remain---as other @sc{gnu} software currently is---the technicalleader in the field.This release represents the latest phase of work in strengthening thecompiler on a variety of points. It includes many months ofwork concentrated on fixing many of the more egregious bugs thatpresented themselves in the compiler recently.@ignore@c FIXME-- update?Nearly 85% of all bugs reported in the period of February to Septemberof 1992 were fixed as part of the work in the first phase.@end ignoreIn the coming months, we hope to continue expanding and enhancing thequality and dependability of the industry's only freely redistributableC++ compiler.@node Changes@chapter Changes in Behavior in @sc{gnu} C++The @sc{gnu} C++ compiler continues to improve and change. A major goalof our work has been to continue to bring the compiler into compliancewith the draft @sc{ansi} C++ standard, and with @cite{The Annotated C++Reference Manual} (the @sc{arm}). This section outlines most of theuser-noticeable changes that might be encountered during the normalcourse of use.@menu* Summary of Phase 1.3::* Major changes::* New features::* Enhancements and bug fixes::* Problems with debugging::@end menu@node Summary of Phase 1.3@section Summary of Changes in Phase 1.3The bulk of this note discusses the cumulative effects of the @sc{gnu} C++Renovation Project to date. The work during its most recent phase (1.3)had these major effects:@itemize @bullet@item The standard compiler driver @code{g++} is now the faster compiledversion, rather than a shell script.@item Nested types work much better; notably, nesting is no longerrestricted to nine levels.@item Better @sc{arm} conformance on member access control.@item The compiler now always generates default assignment operators(@samp{operator =}), copy constructors (@samp{X::X(X&)}), and defaultconstructors (@samp{X::X()}) whenever they are required.@item The new draft @sc{ansi} standard keyword @code{mutable} is supported.@item @samp{-fansi-overloading} is the default, to comply better withthe @sc{arm} (at some cost in compatibility to earlier versions of @sc{gnu} C++).@item More informative error messages.@item System include files are automatically treated as if they werewrapped in @samp{extern "C" @{ @}}.@item The new option @samp{-falt-external-templates} provides alternatetemplate instantiation semantics.@item Operator declarations are now checked more strictly.@item You can now use template type arguments in the template parameter list.@item You can call the destructor for any type.@item The compiler source code is better organized.@item You can specify where to instantiate template definitions explicitly.@end itemizeMuch of the work in Phase 1.3 went to elimination of known bugs, as wellas the major items above.During the span of Phase 1.3, there were also two changes associatedwith the compiler that, while not specifically part of the C++Renovation project, may be of interest:@itemize @bullet@item @code{gcov}, a code coverage tool for @sc{gnu cc}, is now availablefrom Cygnus Support. (@code{gcov} is free software, but the @sc{fsf} has notyet accepted it.) @xref{Gcov,, @code{gcov}: a Test Coverage Program,gcc.info, Using GNU CC}, for more information (in Cygnus releases ofthat manual).@item @sc{gnu} C++ now supports @dfn{signatures}, a language extension toprovide more flexibility in abstract type definitions. @xref{C++Signatures,, Type Abstraction using Signatures, gcc.info, Using GNU CC}.@end itemize@node Major changes@section Major ChangesThis release includes four wholesale rewrites of certain areas ofcompiler functionality:@enumerate 1@item Argument matching. @sc{gnu} C++ is more compliant with the rulesdescribed in Chapter 13, ``Overloading'', of the @sc{arm}. This behavior isthe default, though you can specify it explicitly with@samp{-fansi-overloading}. For compatibility with earlier releases of@sc{gnu} C++, specify @samp{-fno-ansi-overloading}; this makes the compilerbehave as it used to with respect to argument matching and name overloading.@item Default constructors/destructors. Section 12.8 of the @sc{arm}, ``CopyingClass Objects'', and Section 12.1, ``Constructors'', state that acompiler must declare such default functions if the user does notspecify them. @sc{gnu} C++ now declares, and generates when necessary,the defaults for constructors and destructors you might omit. Inparticular, assignment operators (@samp{operator =}) behave the same waywhether you define them, or whether the compiler generates them bydefault; taking the address of the default @samp{operator =} is nowguaranteed to work. Default copy constructors (@samp{X::X(X&)}) nowfunction correctly, rather than calling the copy assignment operator forthe base class. Finally, constructors (@samp{X::X()}), as well asassignment operators and copy constructors, are now available wheneverthey are required.@c XXX This may be taken out eventually...@item Binary incompatibility. There are no new binary incompatibilitiesin Phase 1.3, but Phase 1.2 introduced two binary incompatibilities withearlier releases. First, the functionality of @samp{operatornew} and @samp{operator delete} changed. Name encoding(``mangling'') of virtual table names changed as well. Librariesbuilt with versions of the compiler earlier than Phase 1.2 must becompiled with the new compiler. (This includes the Cygnus Q2progressive release and the FSF 2.4.5 release.)@item New @code{g++} driver.A new binary @code{g++} compiler driver replaces the shell script.The new driver executes faster.@end enumerate@node New features@section New features@itemize @bullet@itemThe compiler warns when a class contains only private constructorsor destructors, and has no friends. At the request of some of ourcustomers, we have added a new option, @samp{-Wctor-dtor-privacy} (on bydefault), and its negation, @samp{-Wno-ctor-dtor-privacy}, to controlthe emission of this warning. If, for example, you are working towardsmaking your code compile warning-free, you can use @w{@samp{-Wall-Wno-ctor-dtor-privacy}} to find the most common warnings.@itemThere is now a mechanism which controls exactly when templates areexpanded, so that you can reduce memory usage and program size and alsoinstantiate them exactly once. You can control this mechanism with theoption @samp{-fexternal-templates} and its corresponding negation@samp{-fno-external-templates}. Without this feature, space consumed bytemplate instantiations can grow unacceptably in large-scale projectswith many different source files. The default is@samp{-fno-external-templates}.You do not need to use the @samp{-fexternal-templates} option whencompiling a file that does not define and instantiate templates used inother files, even if those files @emph{are} compiled with@samp{-fexternal-templates}. The only side effect is an increase inobject size for each file that was compiled without@samp{-fexternal-templates}.When your code is compiled with @samp{-fexternal-templates}, alltemplate instantiations are external; this requires that the templatesbe under the control of @samp{#pragma interface} and @samp{#pragmaimplementation}. All instantiations that will be needed should be inthe implementation file; you can do this with a @code{typedef} thatreferences the instantiation needed. Conversely, when you compile usingthe option @samp{-fno-external-templates}, all template instantiations areexplicitly internal.@samp{-fexternal-templates} also allows you to finally separate classtemplate function definitions from their declarations, thus speeding upcompilation times for every file that includes the template declaration.Now you can have tens or even hundreds of lines in templatedeclarations, and thousands or tens of thousands of lines in templatedefinitions, with the definitions only going through the compiler onceinstead of once for each source file. It is important to note that youmust remember to externally instantiate @emph{all} templates that areused from template declarations in interface files. If you forget to dothis, unresolved externals will occur.In the example below, the object file generated (@file{example.o}) willcontain the global instantiation for @samp{Stack<int>}. If other typesof @samp{Stack} are needed, they can be added to @file{example.cc} orplaced in a new file, in the same spirit as @file{example.cc}.@code{foo.h}:@smallexample@group#pragma interface "foo.h"template<class T>class Stack @{ static int statc; static T statc2; Stack() @{ @} virtual ~Stack() @{ @} int bar();@};@end group@end smallexample@code{example.cc}:@smallexample@group#pragma implementation "foo.h"#include "foo.h"typedef Stack<int> t;int Stack<int>::statc;int Stack<int>::statc2;int Stack<int>::bar() @{ @}@end group@end smallexampleNote that using @samp{-fexternal-templates} does not reduce memory usagefrom completely different instantiations (@samp{Stack<Name>} vs.@samp{Stack<Net_Connection>}), but only collapses different occurrencesof @samp{Stack<Name>} so that only one @samp{Stack<Name>} is generated.@samp{-falt-external-templates} selects a slight variation in thesemantics described above (incidentally, you need not specify bothoptions; @samp{-falt-external-templates} implies@samp{-fexternal-templates}). With @samp{-fexternal-templates}, the compiler emits a definition in theimplementation file that includes the header definition, @emph{even if}instantiation is triggered from a @emph{different} implementation file(e.g. with a template that uses another template).With @samp{-falt-external-templates}, the definition always goes in theimplementation file that triggers instantiation.For instance, with these two header files---@example@exdent @file{a.h}:#pragma interfacetemplate <class T> class A @{ @dots{} @};@exdent @file{b.h}:#pragma interface
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -