The _Export function specifier (C++ only)
Use the
_Export keyword with a function name
to declare that it is to be exported (made available to other modules). You
must define the function in the same translation unit in which you use the _Export keyword.
For example: int _Export anthony(float); The above
statement exports the function anthony, if you define the
function within the translation unit. The _Export keyword
must immediately precede the function name. If the _Export keyword
is repeated in a declaration, z/OS® XL
C++ issues
a warning when you specify the INFO(GEN) option.
If you apply the
_Export keyword
to a class, the z/OS XL
C++ compiler
automatically exports all members of the class, whether static, public, private,
or protected. However, if you want it to apply to individual
class members, then you must apply it to each member that can be referenced.
The following class definitions demonstrate this. class A {
public:
int iii() {
printf("Hi from A::iii()\n");
aaa();
printf("Call to A::ccc() returned %c\n", ccc());
return 88;
}
static void _Export sss();
protected:
void _Export aaa();
private:
char _Export ccc();
};
class _Export B {
public:
int iii() {
printf("Hi from B::iii()\n");
aaa();
printf("Call to B::ccc() returned %c\n", ccc());
return 99;
}
static void sss();
protected:
void _Export aaa();
private:
char _Export ccc();
};In the example below, both
X::Print() and X::GetNext() will
be exported. class _Export X {
public:
...
void static Print();
int GetNext();
...
};
void X:: static Print() {
...
}
int X::GetNext() {
...
}The above examples demonstrate that you can
either export specific members of a class or the entire class itself. Note
that the _Export keyword can be applied to class tags in
nested class declarations.