Xref: utzoo gnu.g++.lib.bug:288 comp.lang.c++:6437 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!dcl-cs!aber-cs!pcg From: pcg@aber-cs.UUCP (Piercarlo Grandi) Newsgroups: gnu.g++.lib.bug,comp.lang.c++ Subject: Re: String class seems unusable in global constructors Summary: You cannot do that... Message-ID: <1633@aber-cs.UUCP> Date: 12 Feb 90 23:22:40 GMT Reply-To: pcg@cs.aber.ac.uk (Piercarlo Grandi) Followup-To: comp.lang.c++ Distribution: gnu Organization: Dept of CS, UCW Aberystwyth (Disclaimer: my statements are purely personal) Lines: 41 In article thoth@shark.cis.ufl.edu (Gilligan) writes: Has anyone addressed the issue of libraries that depend on globally constructed data? Yes, and ... Is there any way to insure that the Strings package gets initialized before I try to use them? I haven't read of any way yet. There is no way. The only guaranteed order of construction is within a source file. You cannot depend on global constructors in other files. Is such an extension a good idea? No, because it would require a quite smart linker, which could be done, and it would require looking at a C++ program as a whole, even if broken in lots of little pieces. So far, this is not the case. Each C/C++ source file is fully independent (note that #include *replicates* code in all the source files). The only alternatives: 1) Require all library classes to not depend on ANY global constructed data Oh yes. 2) document this dependency, so that any classes that use the afflicted class in their constructors can mention the fact that THEY can't be globally constructed either. Oh no. The third alternative is not to use globally constructed objects at all. Initialize everything in your 'main' explicitly. It is a bit backwards... -- Piercarlo "Peter" Grandi | ARPA: pcg%cs.aber.ac.uk@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcvax!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk