C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)
and the structure t1 specify _lowmem, storage for them is not allocated in the extended segment.
Instead, storage is allocated in the user data space.
Export Attribute (Native C and C++ Only)
The export$ and import$ keywords are supported only on native C/C++. These keywords
export and import functions and data to and from a DLL, SRL, or PIC program. They specify whether
a defined or declared class is to be exported or imported, respectively.
export-attribute:
export$
import$
export$
indicates that a specification is a definition and its associated members will be exported.
import$
indicates that a specification is only a declaration and that the definition will be found through
external linkage to a library where the associated members are exported. If applied to a
definition, the definition will be treated as a declaration.
Usage Guidelines for the Export Attribute
• The keyword export$ may only be used with a definition. If specified for a declaration, and
its definition is not within the compilation unit, an error is generated. If export$ is applied
to a tentative definition, the compiler treats the tentative definition as a real definition. In C,
a tentative definition is a declaration of an identifier of an object that has file scope without
an initializer, and without the storage class specifier extern.
• The keyword import$ may only be used with a declaration. If specified for a definition, an
error is generated. If it is applied to a tentative definition, the compiler treats the tentative
definition as a declaration.
• If a single module in a program has both an import$ and an export$ attribute specified
for the same function or object, the export$attribute takes precedence over the import$
attribute. The compiler generates a warning.
• These keywords cannot be applied to static functions, static data, or auto data. The compiler
issues an error for these assignments.
Examples for Native C/C++
For a complete programming example using export$ and import$ and producing a DLL, see
Examples (page 306).
import$ extern int I; /* OK--this is a data declaration*/
export$ extern int j = 1; /*OK--this is a data definition*/
export$ static int si; /*Error: static data */
import$ static int si = 0; /* Error: static data */
import$ extern int j; /* Warning: already specified as export$*/
import extern int i1 = 1; /* Error: this is a definition*/
export$ extern int i2; /* Error if i2 is not defined later*/
export$ int i3; /*Causes tentative def to be treated as a real def*/
import$ int i4; /*Causes tentative def to be treated as declaration*/
export$ static foo1 () {} /*Error: static function */
import$ static foo2 () {} /*Error:static function */
export$ extern foo3 () {} /* OK - extern function definition */
export$ extern foo4 (); /*Error: if foo4 not defined later*/
import$ extern foo5 (); /*OK - extern function declaration*/
import$ extern foo6 () {} /*Error: extern function definition */
Usage Guidelines for the Export Attribute (Native C++ Only)
• In C++, export$ and import$ can be specified for class definitions, in addition to for
member functions and static data members. When given for a class definition, these keywords
specify that the entire class is either exported or imported, including any Computer Generated
Declarations 51