Commit fc72b380 by Jason Merrill Committed by Jason Merrill

re PR c++/15815 (Update #pragma interface and #pragma implementation documentation.)

        PR c++/15815
        * doc/extend.texi (C++ Interface): Correct information and
        discourage use.

From-SVN: r84210
parent 25069b42
2004-07-07 Jason Merrill <jason@redhat.com>
PR c++/15815
* doc/extend.texi (C++ Interface): Correct information and
discourage use.
2004-07-07 Vladimir Makarov <vmakarov@redhat.com> 2004-07-07 Vladimir Makarov <vmakarov@redhat.com>
PR target/16130 PR target/16130
......
...@@ -7940,37 +7940,25 @@ almost certainly break things. ...@@ -7940,37 +7940,25 @@ almost certainly break things.
another way to control placement of these constructs. another way to control placement of these constructs.
@node C++ Interface @node C++ Interface
@section Declarations and Definitions in One Header @section #pragma interface and implementation
@cindex interface and implementation headers, C++ @cindex interface and implementation headers, C++
@cindex C++ interface and implementation headers @cindex C++ interface and implementation headers
C++ object definitions can be quite complex. In principle, your source
code will need two kinds of things for each object that you use across
more than one source file. First, you need an @dfn{interface}
specification, describing its structure with type declarations and
function prototypes. Second, you need the @dfn{implementation} itself.
It can be tedious to maintain a separate interface description in a
header file, in parallel to the actual implementation. It is also
dangerous, since separate interface and implementation definitions may
not remain parallel.
@cindex pragmas, interface and implementation @cindex pragmas, interface and implementation
With GNU C++, you can use a single header file for both purposes.
@quotation @code{#pragma interface} and @code{#pragma implementation} provide the
@emph{Warning:} The mechanism to specify this is in transition. For the user with a way of explicitly directing the compiler to emit entities
nonce, you must use one of two @code{#pragma} commands; in a future with vague linkage (and debugging information) in a particular
release of GNU C++, an alternative mechanism will make these translation unit.
@code{#pragma} commands unnecessary.
@end quotation
The header file contains the full definitions, but is marked with @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
@samp{#pragma interface} in the source code. This allows the compiler most cases, because of COMDAT support and the ``key method'' heuristic
to use the header file only as an interface specification when ordinary mentioned in @ref{Vague Linkage}. Using them can actually cause your
source files incorporate it with @code{#include}. In the single source program to grow due to unnecesary out-of-line copies of inline
file where the full implementation belongs, you can use either a naming functions. Currently (3.4) the only benefit of these
convention or @samp{#pragma implementation} to indicate this alternate @code{#pragma}s is reduced duplication of debugging information, and
use of the header file. that should be addressed soon on DWARF 2 targets with the use of
COMDAT groups.
@table @code @table @code
@item #pragma interface @item #pragma interface
...@@ -8020,9 +8008,6 @@ an implementation file whenever you would include it from ...@@ -8020,9 +8008,6 @@ an implementation file whenever you would include it from
implementation}. This was deemed to be more trouble than it was worth, implementation}. This was deemed to be more trouble than it was worth,
however, and disabled. however, and disabled.
If you use an explicit @samp{#pragma implementation}, it must appear in
your source file @emph{before} you include the affected header files.
Use the string argument if you want a single implementation file to Use the string argument if you want a single implementation file to
include code from multiple header files. (You must also use include code from multiple header files. (You must also use
@samp{#include} to include the header file; @samp{#pragma @samp{#include} to include the header file; @samp{#pragma
...@@ -8040,10 +8025,10 @@ multiple implementation files. ...@@ -8040,10 +8025,10 @@ multiple implementation files.
effect on function inlining. effect on function inlining.
If you define a class in a header file marked with @samp{#pragma If you define a class in a header file marked with @samp{#pragma
interface}, the effect on a function defined in that class is similar to interface}, the effect on an inline function defined in that class is
an explicit @code{extern} declaration---the compiler emits no code at similar to an explicit @code{extern} declaration---the compiler emits
all to define an independent version of the function. Its definition no code at all to define an independent version of the function. Its
is used only for inlining with its callers. definition is used only for inlining with its callers.
@opindex fno-implement-inlines @opindex fno-implement-inlines
Conversely, when you include the same header file in a main source file Conversely, when you include the same header file in a main source file
...@@ -8194,9 +8179,6 @@ management. Code written for the Borland model will work fine, but ...@@ -8194,9 +8179,6 @@ management. Code written for the Borland model will work fine, but
each translation unit will contain instances of each of the templates it each translation unit will contain instances of each of the templates it
uses. In a large program, this can lead to an unacceptable amount of code uses. In a large program, this can lead to an unacceptable amount of code
duplication. duplication.
@xref{C++ Interface,,Declarations and Definitions in One Header}, for
more discussion of these pragmas.
@end enumerate @end enumerate
@node Bound member functions @node Bound member functions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment