Topic: file-scope objects in libraries
Author: lmb@ibmpa.awdpa.ibm.com
Date: Thu, 13 Feb 92 04:04:38 GMT Raw View
Within the source files or corresponding object files that are bound together
to form an executable, all file-scope objects must be retained and initialized
whether or not they are referenced from elsewhere in the program. For
discussion purposes, call the object "unused" and the object file "unused.o".
The question is, what can be said if unused.o is a library member?
Traditionally, a binder includes from a library only those members that
resolve otherwise undefined symbols. If this were the rule, unused.o would
not be included.
Yet if the rule were to include such members, then binding against a library
might include many unrelated objects, causing unwanted initialization code
to be executed. Furthermore, linking would produce unreproducible results
when new members are added.
The C++ implementations I've tried treat this question in conflicting ways.
Larry Breed lmb@ibmpa.awdpa.ibm.com uunet!ibmsupt!lmb
vnet lmbreed@ausvmq phone {415-855,tl-465}-4460
--