Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a statically linked extension for sqlite?

Tags:

c

sqlite

sqlite3_auto_extension looks like a good way to register a statically linked extension. But I don't understand the callback declaration:


void (*xEntryPoint)(void);

Shouldn't the callback be like sqlite3_extension_init?


int sqlite3_extension_init(
  sqlite3 *db,
  char **pzErrMsg,
  const sqlite3_api_routines *pApi
)

like image 967
Sergey Skoblikov Avatar asked Apr 07 '26 10:04

Sergey Skoblikov


1 Answers

I'm puzzled too why the callback is declared like that. sqllite calls it like:

xInit(db, &zErrmsg, &sqlite3Apis);

So you should have e.g.

int my_extension(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi)
{
  //register stuff
  return 0; //ok
}

...
sqlite3_auto_extension((void*)my_extension);
like image 126
nos Avatar answered Apr 09 '26 23:04

nos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!