C++ User's Guide

The Template Repository

The template repository stores template instances between separate compilations so that template instances are compiled only when necessary. The template repository contains all nonsource files needed for template instantiation when using the external instances method. The repository is not used for other kinds of instances.

Repository Structure

The template repository is contained, by default, within the Sun WorkShop Cache directory (SunWS_cache). The Sun WorkShop Cache directory is contained within the directory in which the output files will be placed. You can change the name of the cache directory by setting the SUNWS_CACHE_NAME environment variable.

Writing to the Template Repository

When the compiler must store template instances, it stores them within the template repository corresponding to the output file. That is,

demo% CC -o sub/a.o a.cc

this command line:

writes the object file to ./sub/a.o and writes template instances into the repository contained within ./sub/SunWS_cache. If the cache directory does not exist, and the compiler needs to instantiate a template, the directory is created for you.

You can specify an alternate repository location with the -ptrdirectory option.

Reading From Multiple Template Repositories

The compiler reads from the template repositories corresponding to the object files that it reads. That is,

demo% CC sub1/a.o sub2/b.o

this command line:

reads from ./sub1/SunWS_cache and ./sub2/SunWS_cache, and, if necessary, writes to ./SunWS_cache.

Do not specify multiple repositories by giving multiple -ptr options. You can only use -ptr to specify a single repository location.

Sharing Template Repositories

Do not share template repositories among multiple programs or libraries. That is, the following approach is not supported and can result in inconsistent results and random link errors.

demo% CC a.cc
demo% CC b.cc

In practice, this means you must either compile separate programs (or libraries) in separate directories, or clean out the template repository between each program or library compilation.