Aerospike wrapper/driver for vibe.d ?

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 28 03:54:01 PST 2017


On Saturday, 28 January 2017 at 09:59:10 UTC, Rico Decho wrote:
> I agree, one step at a time...
>
> Anyway, as I've never used D's type introspection and 
> compile-time code generation, my options are quite limited at 
> the moment :(

Binding to C is really, really easy for most cases. E.g. for a 
library
called fancyLib with a C header fancyLib.h

// fancyLib.h, just for reference
struct S
{
     int a, b;
}
char const *fancyCFunction(int a, long b, struct S s);

//fancyLib.d
import core.stdc.config : c_long;
struct S
{
     int a, b;
}
extern(C) const(char)* fancyCFunction(int a, c_long b, S s);

//myCode.d
import fancyLib;
void main()
{
     auto res = fancyCFunction(4, 53, S(1, 1));
}

compile with:
dmd fancyLib.d myCode.d -L-lfancyLib
or add fancyLib to "libs" if you use dub.


More information about the Digitalmars-d mailing list