To use TEMPINC, you must structure your application
as follows:
Declare your class templates and function templates in template
declaration files. This file must have the same file name as the template
definition file and an extension or LLQ of .h. In the following
example, the template declaration file is named stack.h.
You
can identify a template declaration file in either of the following
ways:
In the UNIX file system: /usr/src/stack.h
In a PDS: MYUSERID.USER.H(STACK)
For each template declaration file, create a template definition
file. This file must have the same file name as the template declaration
file and an extension or LLQ of .c. For a class template,
this file defines all of the member functions and static data members.
For a function template, this file defines the function.
You can
identify a template definition file in either of the following ways:
In the UNIX file system: /usr/src/stack.c
In a PDS: MYUSERID.USER.C(STACK)
In your source program, specify an #include statement
for each template declaration file.
In each template declaration file, conditionally include the corresponding
template definition file if the __TEMPINC__ macro is not defined.
This produces the following results:
Whenever you compile with NOTEMPINC, the template defnition
file is included.
Whenever you compile with TEMPINC, the compiler does
not include the template definition file. Instead, the compiler looks
for a file with the same name as the template declaration file and
extension .c the first time it needs a particular instantiation.
If the compiler subsequently needs the same instantiation, it uses
the copy stored in the template include directory.