Calling D function from C

Emil Madsen sovende at gmail.com
Mon Oct 18 04:28:17 PDT 2010


Hopefully one could use printf, and tbh I dont like the hole garbage
collector thingy :)

2010/10/12 Denis Koroskin <2korden at gmail.com>

> On Tue, 12 Oct 2010 11:46:39 +0400, Emil Madsen <sovende at gmail.com> wrote:
>
>  wouldn't compiling, without garbage collector help too?
>>
>> 2010/10/12 Denis Koroskin <2korden at gmail.com>
>>
>>  On Tue, 12 Oct 2010 08:10:31 +0400, Daniel Worthington <
>>> daniel.worthington at gmail.com> wrote:
>>>
>>>  Linking with the phobos lib got it to compile, but I get a Bus Error
>>> when
>>>
>>>> running: EXC_BAD_ACCESS (SIGBUS). Playing with the code a bit and
>>>> looking
>>>> at
>>>> the crash reports, it looks like this happens whenever the D code tries
>>>> to
>>>> allocate memory.
>>>>
>>>> Do you think this is an issue of using dmd and gcc together? I'm on Mac
>>>> OS
>>>> X.
>>>>
>>>> Daniel
>>>>
>>>>
>>> I think that's because you skipped some initialization for D.
>>> At the very least, a GC needs to be initialized first.
>>>
>>> Try calling gc_init() (defined in core.memory) and thread_attachThis()
>>> (core.thread) because invoking other D code.
>>>
>>> That should help.
>>>
>>>
>>
>>
>>
> It would, but then are you okay with memory leaks (i.e. writeln might
> allocate something)?
>



-- 
// Yours sincerely
// Emil 'Skeen' Madsen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20101018/99131a09/attachment.html>


More information about the Digitalmars-d-learn mailing list