2.5.2. Instantiation Modes. Altium TriCore
Werbung
Werbung
TASKING VX-toolset for TriCore User Guide
5. When the compiler compiles a file, it reads the
.ii
file for that file and obeys the instantiation requests therein. It produces a new object file containing the requested template entities (and all the other things that were already in the object file).
6. The prelinker repeats steps 3-5 until there are no more instantiations to be adjusted.
7. The object files are linked together. The linker discards duplicate definitions of template entities.
Once the program has been linked correctly, the
.ii
files contain a complete set of instantiation assignments. From then on, whenever source files are recompiled, the compiler will consult the
.ii
files and do the indicated instantiations as it does the normal compilations. That means that, except in cases where the set of required instantiations changes, the prelink step from then on will find that all the necessary instantiations are present in the object files and no instantiation assignment adjustments need be done.
That's true even if the entire program is recompiled.
If you provide a specialization of a template entity somewhere in the program, the specialization will be seen as a definition by the prelinker. Since that definition satisfies whatever references there might be to that entity, the prelinker will see no need to request an instantiation of the entity. If you add a specialization to a program that has previously been compiled, the prelinker will notice that too and remove the assignment of the instantiation from the proper
.ii
file.
The
.ii
files should not, in general, require any manual intervention. One exception: if a definition is changed in such a way that some instantiation no longer compiles (it gets errors), and at the same time a specialization is added in another file, and the first file is being recompiled before the specialization file and is getting errors, the
.ii
file for the file getting the errors must be deleted manually to allow the prelinker to regenerate it.
If you supplied the option-v to the control program cctc, and the prelinker changes an instantiation assignment, the prelinker will issue messages like:
C++ prelinker: A<int>::f() assigned to file test.o
C++ prelinker: executing: cctc -c test.cc
The automatic instantiation scheme can coexist with partial explicit control of instantiation by you through the use of pragmas or command line specification of the instantiation mode. See the following sections.
The automatic instantiation mode is enabled by default. It can be turned off by the
. If automatic instantiation is turned off, the extra information about template entities that could be instantiated in a file is not put into the object file.
2.5.2. Instantiation Modes
Normally, when a file is compiled, template entities are instantiated everywhere where they are used.
The overall instantiation mode can, however, be changed by a command line option:
--instantiate=none
Do not automatically create instantiations of any template entities.
--instantiate=used
70
Herunterladen
Werbung