C、 如何传递sqlite3数据库句柄
我正在尝试制作一些用于sqlite数据库的UTIL。 为此,我创建了sqlite3_ut.h和sqlite3_ut.c文件 sqlite_ut.hC、 如何传递sqlite3数据库句柄,c,sqlite,C,Sqlite,我正在尝试制作一些用于sqlite数据库的UTIL。 为此,我创建了sqlite3_ut.h和sqlite3_ut.c文件 sqlite_ut.h #ifndef sqlite3_ut_h #define sqlite3_ut_h #include <stdio.h> #include "sqlite3.h" int drop_table(sqlite3 handle); #endif sqlite_ut.h包含在主文件中 sqlite3 *db; int rc = sql
#ifndef sqlite3_ut_h
#define sqlite3_ut_h
#include <stdio.h>
#include "sqlite3.h"
int drop_table(sqlite3 handle);
#endif
sqlite_ut.h包含在主文件中
sqlite3 *db;
int rc = sqlite3_open("m_test.db", &db);
if (rc)...
//error here
int dropped = drop_table(db);
显然,我不能正确地将打开的数据库的句柄转移到drop_table函数,该函数是sqlite3类型的
如何使用建议的程序配置来实现这一点?SQLite3句柄的类型是
SQLite3*
,而不是SQLite3
。重新定义drop\u表
,如下所示:
int drop_table(sqlite3 *handle) { … }
为什么不呢,你试过了吗?你有错误吗?嘿,乔。我在这里遇到了麻烦。用C标题和C文件编译C++程序,现在显示“未定义的引用DROPH表”消息。怎么办?谢谢。我将尽快尝试此选项:)
int drop_table(sqlite3 *handle) { … }