I have to develop an application that can use both sqlite2 dbs and sqlite3 dbs.
I have compiled fine both the libraries and my trial code looks like:
#include <stdio.h> #include "sqlite.h" #include "sqlite3.h"
int main(int argc, char *argv[])
{
int err;
sqlite *ver2;
sqlite3 *ver3;
char path2[]="trial2.db";
char path3[]="trial3.db";
ver2 = sqlite_open(path2, 0, NULL);
if (ver2!=NULL)
{
// Ok for version 2
sqlite_close(ver2);
return 2;
}
err = sqlite3_open(path3, &ver3);
if (err==SQLITE_OK)
{
// OK for version 3
sqlite3_close(ver3);
return 3;
}
return 0;
}Now the troubles .... both sqlite.h and sqlite3.h begins with:
#ifndef _SQLITE_H_ #define _SQLITE_H_ ... #endif
so only one header is included and the other (the latest) is ignored. A possible solution should be to change sqlite3.h with:
#ifndef _SQLITE3_H_ #define _SQLITE3_H_ ... #endif
but now, when I am trying to compile my application I have a lot of 'macro/identifiers redeclared' errors...
For example: macro 'SQLITE_VERSION' redefined or identifier 'sqlite_callback' redeclared or macro 'SQLITE_TEXT' redefined and so on...
Any solution? I really need to use both libraries in my project...
Thanks a lot. Marco Bambini

