🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.lib.bug
Article #569

Re: String class seems unusable in global constructors

#569
From: Piercarlo Grandi
Date: Mon, 12 Feb 1990 23:22
41 lines
2095 bytes
In article <THOTH.90Feb11152541@shark.cis.ufl.edu> 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
Technical Details
Message-ID: <1633@aber-cs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!dcl-cs!aber-cs!pcg

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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