How can I properly import functions from gcx in object.di?

David Nadlinger see at klickverbot.at
Wed Jul 11 07:52:06 PDT 2012


On Tuesday, 10 July 2012 at 23:54:49 UTC, Antti-Ville Tuunainen 
wrote:
> […] However, for any kind of efficiency, the templates also 
> need to be able to directly call functions and/or access the 
> state from src/gc/gcx.d. I cannot just import it, because it 
> won't be available during (user code) compilation. What is the 
> correct approach?

The »correct« approach, as in what is currently done for such 
situations, would be to define the functions you need as 
extern(C) in gc.gc, and then just declare them where you need.

The reason behind this is that core.*, gc.* and rt.* are designed 
to be three completely independent entities, or at least were 
originally supposed to be. Compiler writers would implement the 
rt_ functions, GC implementors would mess around with gc_*, and 
the different parts could be combined by just linking libraries 
together, with the user-facing core.* implementation staying the 
same.

In the case of GC code, the situation is a bit more complex due 
to the GC proxy mechanism, which may or may not go away in the 
future – just look at gc/gc.d, and you should get a pretty good 
idea what's going on.

David


More information about the Digitalmars-d mailing list