|
----------------make 错误如下-------------------
[root@localhost sqlite-qt]# make
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/qt/x86-qtopia/qt/include -o sqlite-qt.o sqlite-qt.cpp
In file included from sqlite-qt.cpp:10:
sqlite-qt-query.cpp:30: cannot declare member function `static int
SqliteQuery::callback(void*, int, char**, char**)' to have static linkage
sqlite-qt-query.cpp: In function `static int SqliteQuery::callback(void*, int,
char**, char**)':
sqlite-qt-query.cpp:30: warning: unused parameter `void*NotUsed'
make: *** [sqlite-qt.o] Error 1
[root@localhost sqlite-qt]#
------------------------------关键代码-------------------
。。。。。。。。。。。。。。
#include "sqlite-qt-query.h"
SqliteQuery::SqliteQuery(char *database)
{
*dbName=*database;
}
void SqliteQuery::query(char *queryStatament)
{
sqlite3 *db;
char *zErrMsg = 0;
int rc;
rc = sqlite3_open(dbName, &db);
if( rc ){
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
return;
}
rc = sqlite3_exec(db, queryStatament, callback, 0, &zErrMsg);//这行有调用callback
if( rc!=SQLITE_OK ){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
}
sqlite3_close(db);
}
static int SqliteQuery::callback(void *NotUsed, int argc, char **argv, char **azColName) //这行,static callback的实现
{
int i;
for(i=0; i<argc; i++)
{
printf("%s = %s\n", azColName, argv ? argv : "NULL");
}
printf("\n");
return 0;
}
。。。。。。。。。。。。。。。。
|
|