Hello.
I have some trouble with C interfacing.
I have a C struct with an integer member and I want to wrap this into a D template. But if I want to access the C API, I have to convert the C struct with the type informations of the D struct.
Example: http://dpaste.dzfl.pl/e3d10755

The question is: How can I write the ptr method? It is very probable, that these conversion is often used, so the ptr method should be fast and without many garbage. And If possible, I want to avoid the GC / Heap. My current approach doesn't avoid the GC complete, but it displace the problem: http://dpaste.dzfl.pl/449f663f

Any further ideas how to solve that?

And yes I want to solve the whole conversion in the ptr method and don't want to write something like that all the time:
----
void foo(ref const Df df) {
    C c = C(cast(int) df.id);
    c_method(&c);
}
----

or

----
void foo(ref const Df df) {
    C c = df.asC();
    c_method(&c);
}
----

Thanks in advance. :)

Reply via email to