SQLite Forum

Using sqlite3_load_extension on windows
Login
You could probably make it look nicer (easier to maintain in the future) by doing something like this:

```
#include <sqlite3ext.h>

SQLITE_EXTENSION_INIT1

#undef SQLITE_EXTENSION_INIT1
#define SQLITE_EXTENSION_INIT1 /* no-op* /

#include "eval.c"
#include "carray.c"
#include "series.c"
#include "btreeinfo.c"

#ifdef _WIN32
__declspec(dllexport)
#endif

int sqlite3_whatever_init(
  sqlite3 *db,
  char **pzErrMsg,
  const sqlite3_api_routines *pApi
){
  SQLITE_EXTENSION_INIT2(pApi);
  if ((rc = sqlite3_eval_init(db, pzErrMsg, pApi)) == SQLITE_OK)
  if ((rc = sqlite3_carray_init(db, pzErrMsg, pApi)) == SQLITE_OK)
  if ((rc = sqlite3_series_init(db, pzErrMsg, pApi)) == SQLITE_OK)
  if ((rc = sqlite3_btreeinfo_init(db, pzErrMsg, pApi)) == SQLITE_OK)
  ;
  return rc;
}
```

To make it clear that SQLITE\_EXTENSION\_INIT1 is only called **once** and ignored in the included files, and provide an init function for the entire DLL ...