digitalmars.D.learn - Linux dll struct class etc
- Mineko (3/3) Jan 27 2014 I can't remember whether or not I've asked this.. But either way,
- FreeSlave (10/14) Jan 28 2014 Do you mean loading classes and structs at runtime? You can do
- Benjamin Thaut (10/13) Jan 28 2014 You should be able to use classes from dynamic libraries just like you
I can't remember whether or not I've asked this.. But either way, is it possible to "export" a class or a struct or something like you do with a windows dll with a linux shared library (dll)?
Jan 27 2014
On Tuesday, 28 January 2014 at 02:40:40 UTC, Mineko wrote:I can't remember whether or not I've asked this.. But either way, is it possible to "export" a class or a struct or something like you do with a windows dll with a linux shared library (dll)?Do you mean loading classes and structs at runtime? You can do this just like in C++ - both library and application should know common base type. Then you need to resolve factory function from library. Factory function may create some derived class instance and return it as base, which known to application. But I'm not sure about GC - you will end up with two garbage collectors, as I presume. This solution also is only for classes, since structs don't support inheritance. Loading structs is more complicated and needs some reflection by hand, but still possible.
Jan 28 2014
Am 28.01.2014 03:40, schrieb Mineko:I can't remember whether or not I've asked this.. But either way, is it possible to "export" a class or a struct or something like you do with a windows dll with a linux shared library (dll)?You should be able to use classes from dynamic libraries just like you use classes from static libraries on linux. On windows the dll support is incomplete and it is not possible at the moment, to use a dll the same way as a static library. It is however possible to use factory functions on windows. But you will run into numerous other problems with windows dlls, so I don't recommend it. In case you are interrested read: http://wiki.dlang.org/DIP45 Kind Regards Benjamin Thaut
Jan 28 2014