作者:坚强萝卜_854 | 来源:互联网 | 2023-08-15 08:04
以下是源码
/*
** When SQLITE_OMIT_WSD is defined, it means that the target platform does
** not support Writable Static Data (WSD) such as global and static variables.
** All variables must either be on the stack or dynamically allocated from
** the heap. When WSD is unsupported, the variable declarations scattered
** throughout the SQLite code must become constants instead. The SQLITE_WSD
** macro is used for this purpose. And instead of referencing the variable
** directly, we use its constant as a key to lookup the run-time allocated
** buffer that holds real variable. The constant is also the initializer
** for the run-time allocated buffer.
**
** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL
** macros become no-ops and have zero performance impact.
*/
#ifdef SQLITE_OMIT_WSD
#define SQLITE_WSD const
#define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
#define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
SQLITE_API int sqlite3_wsd_init(int N, int J);
SQLITE_API void *sqlite3_wsd_find(void *K, int L);
#else
#define SQLITE_WSD
#define GLOBAL(t,v) v
#define sqlite3GlobalConfig sqlite3Config
#endif
我不能理解注释部分的意思,不明白设定这个指令有什么意义!望大侠指点一下!
3 个解决方案
内存分配的问题,
它说的是如果操作系统不支持全局变量和静态变量的时候就要定义这相标记 SQLITE_OMIT_WSD,这时候所有的空间都会在栈或者堆上动态申请.