Small C wrapper in your DUB package?

cy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 8 10:32:20 PDT 2016


I'm tiring of making extern (C) signatures for a million library 
calls and counting out the offset of members of C structures, to 
produce analagous D structures. Couldn't I just make a .c file 
that had my own specialized, opaque, D friendly interface?

I don't really know how to do that. Especially with DUB. Do I put 
it under "libs"? That seems like the only place you can put 
external stuff. Do I have to link my wrapper into a PIC shared 
library, or can I just make a .a static library? Or can I just 
use .o files?

How do I specify that it look for the C wrapper in my package 
directory, rather than systemwide? Just "libs": 
["./helpers/libchelper.a"]? I sure don't want to make a whole 
separate revision controlled project installed in /usr/lib just 
for a chintzy little wrapper for accessing a C library.

I can build any C wrapper binaries in preBuildCommands with just 
a Makefile, so that's no problem. But I'm not sure how to use 
them in my program.


More information about the Digitalmars-d-learn mailing list