This is the mail archive of the gcc@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]

Re: #pragma interface and #pragma implementation


"Steven T. Hatton" <hattons@globalsymmetry.com> writes:

[...]

| > #pragma interface just effects the one header file it appears in.
| > It causes supression of vtables, debug info, and inline functions
| > for declarations (primarily classes) in that header file *unless*
| > there is a corresponding #pragma implementation.  In the implementing
| > .o file, the vtables etc are made global, so they can be shared by
| > other .o files.  The intent is that each foo.h is an interface that
| > is implemented by one foo.c file.
| 
| That is _not_ what these words mean:

But you can take Per's explanation of what the practical things mean. 

[...]

| I believe I now have sufficient grasp of the issue to understand why the 
| inclusion of the same header in multiple source files leads to multiple 
| definitions even with include guards.  It's because each source file is 
| converted to a unique translation unit.

Yep, a translation unit is the complete transitive closure of a file
and #include directives.


| Now what exactly constitutes a header file is a different issue.

Practically, it means anything that can be #included -- so, while it
is common to have files with suffixes .h, .H ... as header files, you
can also have .C files as "header files".  Don't read too much into
"header" in "header files".  In particular, an "implementation file"
could also be (its own) header file.


Let's those pragmas die.

-- Gaby


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