🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.help
Article #191

static constructors and libraries

#191
From: Bradley D. Keister
Date: Tue, 18 Aug 1992 05:38
34 lines
2046 bytes
Several weeks ago I posted a notice that modules in libraries were not
initializing static constructors under g++ 2.2.2 on a SPARC, though
they did so with g++ 2.2.2 on a DECstation.  The details are included
below.  Since I received no feedback at that time, and I need several
library modules which have such constructors for a major project, I've
decided to post this query.  Am I doing something improper?  Is there
a workaround for this, short of compiling all modules with static
constructors and linking them in directly?

Brad Keister
Department of Physics
Carnegie Mellon University
Pittsburgh, PA 15213
(412) 268-2772 (office)
(412) 681-0648 (FAX)

internet:	keister@poincare.phys.cmu.edu
BITNET:		keister%poincare.phys.cmu.edu@CARNEGIE


>> A library which I have developed makes occasional use of static
>> constructors (which generate constants use frequently in
>> applications).  I've just noticed that the SPARC version of g++
>> generates code which initializes those constants to zero, but
>> initializes correctly if the .o file is linked in directly.  If I do
>> the same thing with the DECstation version of g++, I get correct
>> initialization from the code in the library, and the same is true
>> using cfront on the DECstation.
>> 
>> The code which uses the numbers from the static initialization is not
>> itself in any constructor; in fact, it's in main().  I may be
>> misunderstanding the warnings about implementation dependence of
>> static constructors, but I'm surprised that two machine versions of
>> g++ (both 2.2.2) handle it differently.
Technical Details
Message-ID: <9208181338.AA00278@poincare.phys.cmu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!poincare.phys.cmu.edu!keister

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.help,comp.lang.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!poincare.phys.cmu.edu!keister
From: keister@poincare.phys.cmu.edu (Bradley D. Keister)
Subject: static constructors and libraries
Message-ID: <9208181338.AA00278@poincare.phys.cmu.edu>
Sender: daemon@cis.ohio-state.edu
Organization: Gatewayed from the GNU Project mailing list help-g++@prep.ai.mit.edu
Date: Tue, 18 Aug 1992 05:38:20 GMT
Lines: 34