View mode: basic / threaded / horizontal-split · Log in · Help
March 12, 2012
Re: Calling D from C
On 12/03/2012 15:38, Steven Schveighoffer wrote:
<snip>
>> http://dlang.org/phobos/core_runtime.html#initialize
>>
>> And actually, I think this should do everything necessary. No need to call gc_init and
>> thread_attachThis().
>
> Hm... just realized you can't do this, since it's a D function :D

Why can't this be dealt with using an extern (C) wrapper function in the D code?

Stewart.
March 12, 2012
Re: Calling D from C
On Mar 12, 2012, at 9:54 AM, Stewart Gordon <smjg_1998@yahoo.com> wrote:

> On 12/03/2012 15:38, Steven Schveighoffer wrote:
> <snip>
>>> http://dlang.org/phobos/core_runtime.html#initialize
>>> 
>>> And actually, I think this should do everything necessary. No need to call gc_init and
>>> thread_attachThis().
>> 
>> Hm... just realized you can't do this, since it's a D function :D
> 
> Why can't this be dealt with using an extern (C) wrapper function in the D code?

D function names are mangled based on the name of the module they're defined in. For the runtime code, it's easier to wrap extern C calls with D functions.
March 12, 2012
Re: Calling D from C
On Mon, 12 Mar 2012 12:54:25 -0400, Stewart Gordon <smjg_1998@yahoo.com>  
wrote:

> On 12/03/2012 15:38, Steven Schveighoffer wrote:
> <snip>
>>> http://dlang.org/phobos/core_runtime.html#initialize
>>>
>>> And actually, I think this should do everything necessary. No need to  
>>> call gc_init and
>>> thread_attachThis().
>>
>> Hm... just realized you can't do this, since it's a D function :D
>
> Why can't this be dealt with using an extern (C) wrapper function in the  
> D code?

All it does is call the extern(C) rt_init.  It was my bad, if you are in  
D-land, it's definitely better to use Runtime.initialize, but from C, the  
best bet is rt_init.

-Steve
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home