digitalmars.D.learn - problem creating a berkeley db binding
- JT (8/8) Aug 30 2009 i'm trying to create a binding for berkeley db dll and quickly ran into ...
- Sergey Gromov (12/24) Aug 30 2009 This is not a valid C or C++ statement, nor a declaration. It's usually
- JT (2/34) Aug 30 2009 thanks, unfortunately the source is too long to include here, it was a B...
- Mike Parker (12/24) Aug 31 2009 The function name is not 'DB->open'. That's something used in the
- JT (2/30) Aug 31 2009 thank you so much Mike. yeah i just noticed that.
- BLS (3/15) Sep 03 2009 Maybe this project is interesting. last update may 2007
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;)
Aug 30 2009
Sun, 30 Aug 2009 11:28:16 -0400, 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);This is not a valid C or C++ statement, nor a declaration. It's usually hard to translate an invalid code to a different language.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; }If open() is a method of DB struct then it uses some sort of C++ calling convention, probably thiscall. Thiscall is incompatilbe with cdecl, so extern(C) won't work.but real problem is 'DB->open', can anoybody suggest a workaround for this. DB is just a simple struct (struct DB;)I can only guess here that what you want is extern(C++) interface DB { int open(DB_TXN* txnid, char* file, char* database, DBTYPE type, u_int32_t flags, int mode); } But, without a link to source you try to bind to, it's only a wild guess.
Aug 30 2009
Sergey Gromov Wrote:Sun, 30 Aug 2009 11:28:16 -0400, JT wrote:thanks, unfortunately the source is too long to include here, it was a Berkeley DB from Oracle. is there a binding already made for this library. :Pi'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);This is not a valid C or C++ statement, nor a declaration. It's usually hard to translate an invalid code to a different language.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; }If open() is a method of DB struct then it uses some sort of C++ calling convention, probably thiscall. Thiscall is incompatilbe with cdecl, so extern(C) won't work.but real problem is 'DB->open', can anoybody suggest a workaround for this. DB is just a simple struct (struct DB;)I can only guess here that what you want is extern(C++) interface DB { int open(DB_TXN* txnid, char* file, char* database, DBTYPE type, u_int32_t flags, int mode); } But, without a link to source you try to bind to, it's only a wild guess.
Aug 30 2009
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.
Aug 31 2009
Mike Parker Wrote:JT wrote:thank you so much Mike. yeah i just noticed that.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.
Aug 31 2009
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;)
Maybe this project is interesting. last update may 2007
http://code.google.com/p/db4d/
Sep 03 2009









JT <jt nomail.com> 