Windows RT ARM平台上的SQLite3崩溃

时间:2012-09-24 05:51:24

标签: c++ sqlite windows-8 arm

我目前正在通过Visual Studio 2012中的扩展和更新管理器使用SQLite3 v3.7.14下载。当我为Win32编译时,它可以正常工作,但是当我在ARM上编译并运行它时却没有。每当我尝试设置sqlite3_temp_directory时它都会崩溃。我觉得我在这里遵循文档(http://www.sqlite.org/c3ref/temp_directory.html)。

void init()
{
    // Set the temporary directory for sqlite prior to opening the database
    LPCWSTR zPath = Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data();
    char zPathBuf[MAX_PATH + 1];
    memset(zPathBuf, 0, sizeof(zPathBuf));
    WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf), NULL, NULL);
    sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf); // CRASHES HERE ON WINRT

    auto localDataPath = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
    std::wstring path(localDataPath->Data());
    path += L"\\database.sql";

    sqlite3_open16(path.c_str(), &m_DB);
}

我想知道我是否错过了什么?我不知道如何调试这个,也无法找到在WinRT上使用SQLite3或正确使用sqlite3_temp_directory的任何好例子。

更新

事实证明,如果我包含原始sqlite3.h / .c文件,绕过官方预编译的.lib / .dll文件,上面的代码会按预期工作。

1 个答案:

答案 0 :(得分:1)

SQLite3团队告诉我确实存在问题。问题本身要么在SQLite3代码库中,要么在Microsoft MSVC编译器中,并且他们正在积极寻求解决方案。

事实证明,只有在启用优化时才会出现问题,主要原因是/ Og开关。您可以暂时禁用构建优化来解决此问题。