[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
BOUNCE rtl@rtlinux.org: Approval required: Non-member submissionfrom [David Olofson <david.olofson@reologica.se>] (fwd)
- To: rtl@rtlinux.org
- Subject: BOUNCE rtl@rtlinux.org: Approval required: Non-member submissionfrom [David Olofson <david.olofson@reologica.se>] (fwd)
- From: Der Herr Hofrat <der.herr@hofr.at>
- Date: Thu, 31 May 2001 06:30:04 +0200 (CEST)
>From owner-rtl Wed May 30 02:29:58 2001
Received: from mail.space2u.com (sendmail@mail.space2u.com [62.20.1.135])
by hq.fsmlabs.com (8.11.2/8.11.2) with ESMTP id f4U8Tws31787
for <rtl@fsmlabs.com>; Wed, 30 May 2001 02:29:58 -0600
Received: from cutangle.admeo.se ([212.162.175.15])
by mail.space2u.com (8.11.3/8.11.3) with SMTP id f4U8W6K26891
for <rtl@fsmlabs.com>; Wed, 30 May 2001 10:32:07 +0200
From: David Olofson <david.olofson@reologica.se>
Reply-To: david.olofson@reologica.se
Organization: Reologica Instruments AB
To: rtl@fsmlabs.com
Subject: Re: [rtl] RTLinux: C++ static members != good ?
Date: Wed, 30 May 2001 10:25:06 +0200
X-Mailer: KMail [version 1.1.99]
Content-Type: text/plain;
charset="us-ascii"
References: <F26QABZTW5k1Ed28kIN00002f30@hotmail.com> <009b01c0e7dc$16f76fb0$ba7fd13f@baby> <20010529145523.A11694@audi.fzi.de>
In-Reply-To: <20010529145523.A11694@audi.fzi.de>
MIME-Version: 1.0
Message-Id: <01053010250604.18641@cutangle.admeo.se>
Content-Transfer-Encoding: 8bit
On Tuesday 29 May 2001 14:55, Jan Albiez wrote:
> On Mon, May 28, 2001 at 09:10:00PM -0400, Heinz Haeberle wrote:
> > well the only clue I have is that there must be some initialisation code,
> > which is not executed. Like the static objects have to be initialized
> > too. I remember from VxWorks, that there was something which called those
> > init code when you loaded the code. It has to be done only for cpp code.
> > If you make the initialisation in the init code. What's gonna happen
> > then?
>
> The point is: Where is this Init code, why it is not executed, and what do
> I do to get it executed. My knowledege about the internals of the c++
> compiler is not that big ... 8[
Kernel modules aren't "applications", and thus lack the standard C++ (or C,
for that matter) intit/exit code - and consequently, there's nowhere to hook
in the application dependent init code generated by the compiler.
In your main C++ module, you need to do something like
extern "C" {
#include <linux/module.h>
int init_module(void);
void cleanup_module(void);
__do_global_ctors_aux();
__do_global_dtors_aux();
};
and then call __do_global_ctors_aux() from init_module(), and
__do_global_dtors_aux() from cleanup_module(). That way, your global
variables and object instances will be initialized and destroyed properly
when the module is loaded and removed, respectively.
//David Olofson --- Programmer, Reologica Instruments AB
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
`----------------------> http://www.linuxaudiodev.com/maia -'
.- David Olofson -------------------------------------------.
| Audio Hacker - Open Source Advocate - Singer - Songwriter |
`--------------------------------------> david@linuxdj.com -'