problem creating a berkeley db binding

JT jt at nomail.com
Mon Aug 31 19:01:35 PDT 2009


Mike Parker Wrote:

> JT wrote:
> > i'm trying to create a binding for berkeley db dll and quickly ran into some problems, how do i translate statement below.
> > 
> > int DB->open(DB *db, DB_TXN *txnid, const char *file,
> >     const char *database, DBTYPE type, u_int32_t flags, int mode);
> > 
> > my normal approach would be,
> > 
> > extern (C) {
> > 	int function(DB* db, DB_TXN* txnid, char* file, char* database, DBTYPE type, u_int32_t flags, int mode) DB->open;
> > }
> > 
> > but real problem is 'DB->open', can anoybody suggest a workaround for this. DB is just a simple struct (struct DB;)
> 
> The function name is not 'DB->open'. That's something used in the 
> comments. Nearly all functions in Berkeley DB are declared as function 
> pointers used as struct fields. So what you'll want is something like this:
> 
> extern(C):
> 
> struct DB
> {
>      int function(DB* db, DB_TXN* txnid, char* file, char* database, 
> DBTYPE type, u_int32_t flags, int mode) open;
> }
> 
> Along with all of the rest of the DB function pointers and the numerous 
> inner structs declared in the C headers.

thank you so much Mike. yeah i just noticed that.


More information about the Digitalmars-d-learn mailing list