extern(C) with function returning user type
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jul 29 11:20:53 PDT 2015
On Wednesday, 29 July 2015 at 17:59:26 UTC, Kyoji Klyden wrote:
> How would I use a C function that's returning a struct? auto
> doesn't work here, and from what I can tell D can't import C
> headers. (If it really can't then, that would be a very welcome
> feature)
>
> I do have the required libs but I can't create my D obj file so
> I can't really get there.
>
> I know that there htod but, is there anyway I can avoid using
> that?
>
> I'm using GDC, and GCC on Win7
D can't import C header files. And I don't think such a feature
is planned right now.
You have to translate the C declarations to D, both struct and
function. You can do that either manually or using some tool.
If you go the manual route, there's a page on that:
http://dlang.org/ctod.html
For tools, if you're not happy with htod, maybe DStep works
better:
https://github.com/jacob-carlborg/dstep
More information about the Digitalmars-d-learn
mailing list