HIDE_TEMPLATE_DEFINITIONS
when you build your project, you must create or modify a file in your project directory called ProjectNameInstantiations.C
.
The instantiations file
The source directory for every shared library or server that you develop must contain an instantiations file, which defines the template classes that your shared library or server instantiates. This example, MemHeapInstantiations.C
, is taken from the memory heap project:
// $Revision: 1.1 $
#ifndef HIDE_TEMPLATE_DEFINITIONS
#define HIDE_TEMPLATE_DEFINITIONS
#endif
#include "Collections.h"
#include "Storage.h"
#define MAKE_TCollectionOf_DEFINITIONS_VISIBLE
#define MAKE_TComparator_DEFINITIONS_VISIBLE
#define MAKE_TStreamer_DEFINITIONS_VISIBLE
#pragma defineonly
#include "CollectionsImplementation.h"
#pragma define( TCollectionOf<TMemoryHeap> )
#pragma define( TComparator<TMemoryHeap> )
#pragma define( TStreamer<TMemoryHeap> )
#undef MAKE_TCollectionOf_DEFINITIONS_VISIBLE
#undef MAKE_TComparator_DEFINITIONS_VISIBLE
#undef MAKE_TStreamer_DEFINITIONS_VISIBLE
Adding new
instantiations
To add new instantiations to your shared library or server, create or modify the instantiations file for the project that contains your code:
NOTE
If you create a new instantiations file, remember to add it to your
#define MAKE_ClassTemplateName_DEFINITIONS_VISIBLE
#include
statements.
This statement is very important; it tells the compiler to instantiate only the explicitly requested template classes.#pragma defineonly
#pragma define( ClassTemplateName )
#undef MAKE_ClassTemplateName_DEFINITIONS_VISIBLE
.PinkMake
file. ProjectNameInstantiations.C
must be the first file listed in the source:
section for your library or server. Determining which
class templates
to add
To determine which class templates to add to the instantiations file, you must compile and link your project. The final linking pass issues error messages about undefined symbols, which you can use to identify missing class templates. For a template class such as TPileOf<int>
, for example, you might get error messages of this form:
Add the missing class templates to the instantiations file and build your project again. You might need to repeat this process several times to identify all the missing class templates."ld: error-code ERROR: Undefined symbol: TPileOf<int>::MemberFunction"
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Generated with WebMaker