[comp.lang.c++] Multiply defined ctor functions

ark@alice.UUCP (Andrew Koenig) (11/10/89)

In article <33892@cornell.UUCP>, deb@svax.cs.cornell.edu (David Baraff) writes:

> Now suppose a user writes a program, and he uses the
> filename 'foo.C'. If his 'foo.C' contains static objects
> with constructors, the same function will be added in.

> Thus, when the user links with the library that has
> a file named 'foo.C', he'll get a multiply defined error
> since '_STI_foo_C' is defined twice.

> Question: does this happen in 2.0?

In general, no.

The trick is that 2.0 includes, in the name of the _STI_ function,
the name of the first object of global scope that was defined
(not just declared) in that compilation.  There is almost always
such an object.

The point is that such definitions must be unique, so there is an
absolute guarantee against name clashes.
-- 
				--Andrew Koenig
				  ark@europa.att.com