RE: dynamic libraries: custom _init() without losing default _init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>to initialize the dynamic library a custom _init() is called. is it
>possible to call default _init() from the custom one or is there
>another way to invoke a custom function from default _init() or
>directly afterwards?
>
>matze

It would be safer to not override default startup code, but use one of
the following:

Once your code is C++ you can create file-scope instance of some
initialization class so its constructor will do the work. This is most
portable approach.

In case library initialization code must be executed _before_ any C++
object constructor, you may use ".preinit_array"
	static preinit(int argc, char *argv[]);
	static void (*const preinit_ptr) (int argc, char *argv[])
	     __attribute__ ((section (".preinit_array"))) = &preinit;

- Grigory


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux