Luiz Gustavo Bizarro Mirisola wrote:
> 
> On Wed, 30 May 2001, David Olofson wrote:
> 
> > 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.
> 
>         Well, I am not an gcc expert too, but I have a class with one
> static atribute and some static methods and I did not need to do
> anything but using the usual C++ syntax.
>         I have compiled it separately and linked it with the main
> object file of the module.
> the static attribute is an object that does not have a default
> constructor... Indeed it has only a int attribute and some methods
> (the methods call rt-fifo functions). is this relevant?
> 

static C++ members are basically the same as global objects, when they
are of a native type like int, void* etc. they will live in .bss and
be zeroed or in .data when you gave them a value. 
When they are of a class type they will have their default constructor
(if you didn't write one GCC did it for you) called. Or at least that
happens in a normal C++ program and is done by the startup code. 
There are several ways to do this in a kernel module and those
have been mentioned here before, only they have been mentioned 
in connection with global objects not with statics, so looking
for how it is done fro global objects will also solve the static 
problem. I solved it in RTAI by borrowing some parts from libgcc
that do the constructor /destructor calling. The gcc sources especially
libgcc is a good reference to see how it is done.

- Erwin

-- [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