🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gnu.g++.lib.bug
1 messages
1 total messages Started by Piercarlo Grandi Mon, 12 Feb 1990 23:22
Re: String class seems unusable in global constructors
#569
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads