3.3.10. Template instantiation

The ARM compiler does all template instantiations automatically, and makes sure there is only one definition of each template entity left after linking. The compiler does this by emitting template entities in named common sections. Therefore, all duplicate common sections, that is, common sections with the same name, are eliminated by the linker.

Note

You can limit the number of concurrent instantiations of a given template with the --pending_instantiations compiler option.

See C++ Language configuration and object generation for details of the compiler options associated with templates.

Implicit inclusion

When implicit inclusion is enabled, the compiler assumes that if it requires a definition to instantiate a template entity declared in a .h file it can implicitly include the corresponding .cc file to get the source code for the definition. For example, if a template entity ABC::f is declared in file xyz.h, and an instantiation of ABC::f is required in a compilation but no definition of ABC::f appears in the source code processed by the compilation, then the compiler checks to see if a file xyz.cc exists, If this file exists, the compiler processes the file as if it were included at the end of the main source file.

To find the template definition file for a given template entity the compiler has to know the full path name of the file where the template was declared and whether the file was included using the system include syntax (for example, #include <file.h>). This information is not available for preprocessed source containing #line directives. Consequently, the compiler does not attempt implicit inclusion for source code containing #line directives.

The compiler looks for the definition-file suffixes .cc and .CC.

You can turn implicit inclusion mode on or off with the --implicit_include (the default) and --no_implicit_include command-line options. See C++ Language configuration and object generation for details of these options.

Implicit inclusions are only performed during the normal compilation of a file, that is, when not using the -E command-line option (see Setting preprocessor options).

Copyright © 2005 ARM Limited. All rights reserved.ARM DUI 0282B
Non-Confidential