Article View: gnu.gcc.help
Article #49558constructor not called
From: Sebastian L. Brings
Date: Wed, 05 Jan 1994 19:24
Date: Wed, 05 Jan 1994 19:24
41 lines
1885 bytes
1885 bytes
Hello,
the following program fragment is part of the GNU libg++.
it tests correct working, but it doesn't work on my machine yet.
the instance static_foo defined before main() doesn't get initialized,
nb_foos() returns 0. When I put this line into main(), nb_foos()
returns 1. 2 is expected...
My question : from where should the constructor get called when
it is a global object like static_foo. Do I need special c++
startup files? Is it somewhere in __main() ?
I'm using gcc-2.5.7 irix5 with a few modifications for my machine.
Sebastian
-------------------------------------------------------------
// main program for Class Foo
....
#include "Foo.h"
... class Foo
... includes a static var foos set to 0, incremented by constructor,
... decremented by destructor, available via nb_foos()
extern "C" void __init_start();
extern Foo f(void);
extern void g(void);
void
__init_start()
{
Foo::init_foo();
... does not get called, this is correct ...
}
static Foo static_foo( "static_foo"); ...doesn't work...
... from which function the constructor should get called ???
main()
{
assert (Foo::nb_foos() == 2);
Foo automatic_foo( "automatic_foo"); ...works...
... some more stuff also working good...
}
Technical Details
Message-ID:
<940105190340_100112.657_BHJ53-1@CompuServe.COM>Path:
arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!compuserve.COM!100112.657Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,2b957867037e33f,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1994-01-05 11:49:26 PST Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!compuserve.COM!100112.657 From: 100112.657@compuserve.COM (Sebastian L. Brings) Newsgroups: gnu.gcc.help Subject: constructor not called Date: 5 Jan 1994 14:24:16 -0500 Organization: GNUs Not Usenet Lines: 43 Sender: daemon@cis.ohio-state.edu Distribution: gnu Message-ID: <940105190340_100112.657_BHJ53-1@CompuServe.COM>