B-Tree comparison Function for Unicode Keys/Datum -
10-10-2005
, 04:35 AM
Hello,
I use the recent C API of Berkely DB to make a kind of an address book
on Windows, the key/data entries are all saved in unicode format. I
need therefore to provide my own B-Tree comparison function as stated
in the documentation.
I made the same things written there:
int compare_int(DB *dbp, const DBT *a, const DBT *b)
{
int ai, bi;
/*
* Returns:
* < 0 if a < b
* = 0 if a = b
* > 0 if a > b
*/
memcpy(&ai, a->data, sizeof(int));
memcpy(&bi, b->data, sizeof(int));
return (ai - bi);
}
... and put this before opening the DB and after creating it:
dbp->set_bt_compare(dbp, compare_int)
Then I get this failure:
E2034 Cannot convert 'int (* (_closure )(__db *,const __db_dbt *,const
__db_dbt *))(__db *,const __db_dbt *,const __db_dbt *)' to 'int
(*)(__db *,const __db_dbt *,const __db_dbt *)'
E2340 Type mismatch in parameter 2 (wanted 'int (*)(__db *,const
__db_dbt *,const __db_dbt *)', got 'void')
I just wanted to see if this is possible, and eventually to change the
function to whatever suits my program. Any clues?
Regards,
Al |