Subject: C++ q: constructors not called for classes in shared lib ?
To: None <current-users@netbsd.org>
From: Jaromir Dolecek <jdolecek@per4mance.cz>
List: current-users
Date: 02/02/1999 13:20:13
I got into strange error, while playing with KDE 1.1pre2.

There is library kdeui, which contains KQuickHelp implemenetation.
It uses static variable, defined as

	QList<KQuickTip> tips;

In static function KQuickHelp:add(), the variable is used to store
QuickHelp text, the call is made as:

	tips.append(s);

but application using it (kppp, in my case) crashes here, when the binary
is linked against the shared version of library, but works normally
when linked against kdeui statically.  If I change the variable to

	QList<KQuickTip> *tips;

change code using it and explicitely initialize it before first
use, everything is okay for both shared & static.

As I'm C++ dumb, my question may sound silly or even be incorrect,
but here it is:
Is the constructor properly called for static classes when they
reside in shared libs ?
If not, is it error of our implementation or it's error of
code, which uses such classes ?
	
I recall there is similar problem with libpthread library (have
to link statically or the application won't work).

As a side note: it seems to work on Linux, whatever hack they
are doing there. The kppp author is developing it on Linux,
so I guess it's working for him :)

I'm using NetBSD 1.3I/i386 (almost exact snapshot from beginning
of December, only as upgraded to get recent fixes), if it matters.

-- 
Jaromir Dolecek <dolecek@ics.muni.cz>	http://www.ics.muni.cz/~dolecek/
-------------------------------------------------------------------------
It is better never to have been born.  But who among us has such luck?
One in a million, perhaps.