DLL Programmer's Guide for TNS/E Systems

Essential DLL Facility Controls
DLL Programmer’s Guide for TNS/E Systems527252-006
2-13
At a Glance: Files the Linker Brings into a Link
At a Glance: Files the Linker Brings into a Link
Compile-Time Control of Export and Import
The TNS/E C and C++ compilers provide facilities to specify export and import controls
at compile time. The syntax involves a modifier, export$ or import$, which can be
placed on the declaration of an identifier. As their names imply, they cause the
compiler to mark the associated definition as exported or imported, respectively. When
applied to the declaration or definition of an individual function or variable, it affects that
one item. When applied to the declaration of a class, it affects all the symbol definitions
within that class, including auxiliary compiler-generated definitions such as type
identification variables. This facility has several important advantages:
The identifiers can be marked in the source, avoiding the need to place details into
the linker's command stream.
The programmer need not know or enter the "mangled" form of C++ function
names to export them.
When marking a whole class, the programmer need not know its compiler-
generated auxiliary identifiers.
Not only can identifiers be marked exported in some linkfiles and loadfiles, they
can be marked imported in others. Judicious use of this ability can avoid unwanted
multiple definitions, reducing wasted address space and potential ambiguity.
(Linker commands can offer symbols for export, but cannot force them to be
imported.)
The export$ and import$ modifiers are not intended to be used explicitly, but instead to
occur within the expansions of defines. For example, consider the following header file
fragment:
#ifndef export_foo
# define export_foo import$
#endif
export_foo class foo {...}...
When this file is included in routine compilations, the various symbols associated with
this class definition will be marked as undefined, so they must be defined in another
To incorporate in a link: Action:
A linkfile, archive, or
library to open
normally
Insert its qualified file name directly in the
command stream
An archive or
library to search for and
open
Insert its unqualified file name in a -lib
option