[Geany-devel] Geany Newsletter Issue #5

Lex Trotman elextr at xxxxx
Mon May 28 11:27:03 UTC 2012


On 28 May 2012 19:59, Thomas Martitz
<thomas.martitz at student.htw-berlin.de> wrote:
> Am 28.05.2012 11:27, schrieb Frank Lanitz:
>>
>> It's important to note that the dynamic library loading mechanism
>> that loads plugins is C functionality and does not know about C++
>> constructors. This means that global and static objects in the
>> plugin will *not* have their constructors called when the plugin is
>> loaded. Use dynamically created objects as show in the above example.
>>
>
> I'm not sure this is true. libdl should handle this (i.e. call functions
> point to in the init and fini sections).
>
> |__attribute__ ((constructor)) and||__attribute__  ((destructor)) is
> supported works with as well.
>

This doesn't actually call the C++ constructors/destructors in the way
they would be in normally be if the plugin had been statically linked.

This simply labels a C function to be called at dlopen time.  It may
be used to do some initialisation, but you would have to manually call
each constructor, ... too error prone, Franks advice to create
everything dynamically is sound.

Cheers
Lex

> Best regards.
> |
>
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel



More information about the Devel mailing list