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 |
`--------------------------------------> [EMAIL PROTECTED] -'

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to