extern(C) in druntime

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 14 07:20:58 PST 2014


On 11/10/2014 03:48 PM, Steven Schveighoffer wrote:
> Opinion from those in the know:
>
> When extern(C) is used in druntime, my understanding is that the reason
> is twofold:
>
> 1. Because the compiler requires certain symbols for hooks.
> 2. To get around some requirements that "druntime knows better", such as
> purity for things like memory allocation that touch global state.

Sometimes that might be required, but those "hacks" should be on the 
implementation not the call site.

I made a template to bind extern(D) function and I'd like to see it 
replacing most of the extern(C) bindings. It allows typesafe and 
attribute-correct bindings and things break if they aren't kept in sync.

https://github.com/D-Programming-Language/druntime/search?q=externDFunc


More information about the Digitalmars-d mailing list