HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)
Possible Duplicate Symbols in Archive Libraries
If you have built an archive library using automatic instantiation in HP aC++ A.02.00
or A.01.04 and prior versions, and you rebuild that library using the current (compile-time)
instantiation, it is possible that duplicate symbol problems not apparent in the prior
release will generate errors in the current release.
This is because the current default uses the linker, rather than the assigner, to determine
which object file to pick to satisfy instantiation requests.
For example, when your archive library is linked with an application, library objects in
the link may be different than those used when linking the library in a prior release.
Following are two examples of building an archive library; one built with
+inst_auto/+inst_close (the prior default), and the other built with the current
(compile-time) default:
Building an Archive Library with +inst_auto/+inst_close
Suppose for lib.inst_auto.a, the linker chooses foo2.o to resolve symbol x, and
foo3.o to resolve symbol stack <int>, symbols x, y, and stack <int> are each
resolved with no duplicates.
lib.inst_auto.a
-------------------------------------------------
| foo.o | foo2.o | foo3.o |
| | | stack<int> |
| x | x | y |
| y | | |
-------------------------------------------------
Building an Archive Library with Compile-time Instantiation
Suppose for lib.default.a, the linker chooses foo2.o to resolve symbol x, and
foo.o to resolve symbol stack <int>, symbols x, y, and stack <int> are each
resolved, but now there’s a duplicate definition of symbol x. This will cause a linker
duplicate symbol error. This is really a user error, but was not visible before.
lib.default.a
-------------------------------------------------
| foo.o | foo2.o | foo3.o |
| stack<int> | stack<int> | stack<int> |
| x | x | y |
| y | | |
-------------------------------------------------
NOTE: This example is not meant to account for all cases of changed behavior.
C++ Template Tutorial
You can create class templates and function templates. A template defines a group of
classes or functions. A template can have one or more types as parameters. When you
168 Using HP aC++ Templates