上面的代碼是從網上下載下傳下來的,它使用的SQLite版本比較舊,是以在SQLite 3.7.13下編譯不通過,下面需要對編譯錯誤和警告逐一修正。
編譯資訊
原因與修改方法
'Pager' has no member named 'pCodecArg'
在3.7.13版本中,Pager的成員變量pCodecArg名稱修改為pCodec,是以用到pCodecArg變量的地方修改為使用pCodec。
too few arguments to function 'sqlite3PagerPagecount'
原來sqlite3PagerPagecount()函數用傳回值得到頁數量,3.7.13改為用指針參數得到頁數量。
修改前代碼:
Pgno nPage = sqlite3PagerPagecount(p);
修改如下:
<b>int</b> nPage;
sqlite3PagerPagecount(p, &nPage);
too few arguments to function 'sqlite3BtreeRollback'
3.7.13版中sqlite3BtreeRollback()函數增加了個參數,是表示之前SQL語句執行結果的,在網上查了一下,這裡直接傳常量SQLITE_OK。
implicit declaration of function 'sqliteFree'
sqliteFree()函數在3.7.13版本中已經沒有了,修改為使用sqlite3_free()函數。
implicit declaration of function 'sqliteMalloc'
原因同上,修改為使用sqlite3_malloc()函數。
implicit declaration of function 'DATA_TO_PGHDR'
在3.7.13版本中,宏DATA_TO_PGHDR已經被去掉,這裡暫時把該if語句下的代碼全部注釋。
warning: passing argument 2 of 'sqlite3pager_set_codec' from incompatible pointer type
sqlite3pager_set_coedc()函數的第二個參數類型為:<b>void</b> *(*xCodec)(<b>void</b>*, <b>void</b>*,Pgno, <b>int</b>)
而調用的地方傳遞的參數類型為:<b>void</b> * <b>sqlite3Codec</b>(<b>void</b> *pArg, <b>unsigned</b> <b>char</b> *data,Pgno nPageNum, <b>int</b> nMode)
很明顯,第二個參數類型不比對,修改sqlite3Codec()函數的第二個參數類型為void *,注意相應的函數聲明的地方也要修改。
warning: passing argument 3 of 'sqlite3PagerAcquire' from incompatible pointer type
這裡第三個參數類型為void *,實際要求的資料類型為DbPage *,将對應變量類型定義為DbPage *即可。
warning: variable 'bRc' set but not used
這個警告不影響使用,不用改。
warning: 'sqlite3PagerSetCodec' defined but not used
同上
本文轉自 tywali 51CTO部落格,原文連結:http://blog.51cto.com/lancelot/940814,如需轉載請自行聯系原作者