NA01
03-04-2005, 11:47
ho rimesso mano alle mie scarse conoscenze di questo db per fare un programmino stupidissimo.
ho scritto qualcosa come mi ricordavo e non andava nulla. mi dava un'errore sulla open.
sono andato sulla documentazione nel tarrball dei sorgenti e dà ragione al mio codice :eek:
peccato che anche un copia incolla dell'esempio non funziona assolutamente
l'esempio è questo
#include <db.h>
int main(){
DB *dbp; /* DB structure handle */
u_int32_t flags; /* database open flags */
int ret; /* function return value */
/* Initialize the structure. This
* database is not opened in an environment,
* so the environment pointer is NULL. */
ret = db_create(&dbp, NULL, 0);
if (ret != 0) {
/* Error handling goes here */
}
/* Database open flags */
flags = DB_CREATE; /* If the database does not exist,
* create it.*/
/* open the database */
ret = dbp->open(dbp, /* DB structure pointer */
NULL, /* Transaction pointer */
"my_db.db", /* On-disk file that holds the database. */
NULL, /* Optional logical database name */
DB_BTREE, /* Database access method */
flags, /* Open flags */
0); /* File mode (using defaults) */
if (ret != 0) {
/* Error handling goes here */
}
}
ed ecco a voi l'errore
ultio@NA01:~$ gcc db.c -ldb-4.2
db.c: In function `main':
db.c:27: error: incompatible type for argument 4 of indirect function call
db.c:27: error: too many arguments to function
.....
aiuuuuuuuuuttttttttoooooooooooooooo!!!! :D
ciao
ho scritto qualcosa come mi ricordavo e non andava nulla. mi dava un'errore sulla open.
sono andato sulla documentazione nel tarrball dei sorgenti e dà ragione al mio codice :eek:
peccato che anche un copia incolla dell'esempio non funziona assolutamente
l'esempio è questo
#include <db.h>
int main(){
DB *dbp; /* DB structure handle */
u_int32_t flags; /* database open flags */
int ret; /* function return value */
/* Initialize the structure. This
* database is not opened in an environment,
* so the environment pointer is NULL. */
ret = db_create(&dbp, NULL, 0);
if (ret != 0) {
/* Error handling goes here */
}
/* Database open flags */
flags = DB_CREATE; /* If the database does not exist,
* create it.*/
/* open the database */
ret = dbp->open(dbp, /* DB structure pointer */
NULL, /* Transaction pointer */
"my_db.db", /* On-disk file that holds the database. */
NULL, /* Optional logical database name */
DB_BTREE, /* Database access method */
flags, /* Open flags */
0); /* File mode (using defaults) */
if (ret != 0) {
/* Error handling goes here */
}
}
ed ecco a voi l'errore
ultio@NA01:~$ gcc db.c -ldb-4.2
db.c: In function `main':
db.c:27: error: incompatible type for argument 4 of indirect function call
db.c:27: error: too many arguments to function
.....
aiuuuuuuuuuttttttttoooooooooooooooo!!!! :D
ciao