Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
January 03, 2014 External modules | ||||
---|---|---|---|---|
| ||||
This is another short one, is it possible to export/extern (C) an entire module, is it safe? Also, how do you import said module, this one I don't quite get. So, something like this: dll.d: extern (C) module test; int foo() {...} ------------------------- main.d int main(string[] args) { ... (dl loading code for dll.so) module dll = dlsym(lh, "test"); ... } So, aside from the crappy abstraction, something like that? |
January 03, 2014 Re: External modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mineko | On 2014-01-03 14:00, Mineko wrote: > This is another short one, is it possible to export/extern (C) an entire > module, is it safe? > > Also, how do you import said module, this one I don't quite get. > > So, something like this: > > dll.d: > extern (C) module test; > > int foo() {...} > > ------------------------- > main.d > int main(string[] args) > { > ... > (dl loading code for dll.so) > module dll = dlsym(lh, "test"); > ... > } > > So, aside from the crappy abstraction, something like that? You can't import the whole module. You would need to use "dlsym" on each symbol you're interested in. -- /Jacob Carlborg |
January 03, 2014 Re: External modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Friday, 3 January 2014 at 13:03:50 UTC, Jacob Carlborg wrote:
> On 2014-01-03 14:00, Mineko wrote:
>> This is another short one, is it possible to export/extern (C) an entire
>> module, is it safe?
>>
>> Also, how do you import said module, this one I don't quite get.
>>
>> So, something like this:
>>
>> dll.d:
>> extern (C) module test;
>>
>> int foo() {...}
>>
>> -------------------------
>> main.d
>> int main(string[] args)
>> {
>> ...
>> (dl loading code for dll.so)
>> module dll = dlsym(lh, "test");
>> ...
>> }
>>
>> So, aside from the crappy abstraction, something like that?
>
> You can't import the whole module. You would need to use "dlsym" on each symbol you're interested in.
Thank you.
|
January 03, 2014 Re: External modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Friday, 3 January 2014 at 13:03:50 UTC, Jacob Carlborg wrote:
> You can't import the whole module. You would need to use "dlsym" on each symbol you're interested in.
It could potentially be automated with reflection though...
|
January 03, 2014 Re: External modules | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On 2014-01-03 16:05, Adam D. Ruppe wrote: > It could potentially be automated with reflection though... Yes, sure. -- /Jacob Carlborg |
Copyright © 1999-2021 by the D Language Foundation