template instantiation question
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Mar 18 11:26:07 PDT 2015
On 03/18/2015 11:03 AM, Dmitri Makarov wrote:
> When these modules compiled separately, I assume, both a.o and b.o
> contain a definition of i.c.S!void.S.transmogrify() instance.
That is very likely but I played with different three files for a while
and failed to see that.
> how is the symbol redefinition resolved when the three object
> files are linked into a single executable?
There are different kinds of symbols. For example, the following command
on a Linux console will show that template instances are weak symbols
(it is not an error to have one or more weak symbols).
$ nm b.o | grep transmogrify
0000000000000000 W _D1c8__T1CTvZ1C12transmogrifyMFNaNbNiNfZi
'man nm' tells us that W indicates a weak symbol:
"W"
"w" The symbol is a weak symbol that has not been specifically
tagged as a weak object symbol. When a weak defined symbol is
linked with a normal defined symbol, the normal defined symbol
is used with no error. When a weak undefined symbol is linked
and the symbol is not defined, the value of the symbol is
determined in a system-specific manner without error. On some
systems, uppercase indicates that a default value has been
specified.
Ali
More information about the Digitalmars-d-learn
mailing list