This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Constructors and destructors of static variables
- To: Adrian dot Trapletti at wu-wien dot ac dot at
- Subject: Re: Constructors and destructors of static variables
- From: Nick Ing-Simmons <nik at tiuk dot ti dot com>
- Date: Wed, 17 Feb 1999 18:30:51 GMT
- Cc: egcs at egcs dot cygnus dot com
- Organization: via, but not speaking for : Texas Instruments Ltd.
- References: <36CB0718.CD2D03AC@wu-wien.ac.at>
- Reply-To: Nick Ing-Simmons <nik at tiuk dot ti dot com>
Adrian Trapletti <Adrian.Trapletti@wu-wien.ac.at> writes:
>
>Y::Y()
>{
> cout << "constructor Y" << endl;
>}
>
>Y::~Y()
>{
> cout << "destructor Y" << endl;
>}
>--------------------------------
>
>
>While compilation, shared linkage and execution yield:
>
>45: g++ -c X.cc
>46: ld -shared -o X.so X.o
>47: g++ -o main main.cc X.so
>48: main
>constructor X
>destructor X
>
>Is that what we want, or is this a bug? What about y,
BEWARE - you are using cout which is itself a static object.
It is quite possible that Y::Y() is being called before cout
has been constructed (the C++ IO is not linked to your X.so).
Try using write(1,"string",length).
--
Nick Ing-Simmons <nik@tiuk.ti.com>
Via, but not speaking for: Texas Instruments Ltd.