gpt4 book ai didi

iphone - 存储到 'var name' 的值永远不会被读取

转载 作者:行者123 更新时间:2023-12-03 20:22:04 24 4
gpt4 key购买 nike

我在编译器警告方面遇到了一些困难。代码如下:

    const char *sql;
switch (fromVersion) {
case 0:
{
sql = "ALTER TABLE abiliator_options ADD COLUMN new_column00 TEXT NOT NULL DEFAULT 'migrated from version 0'";
}
case 1:
{
sql = "ALTER TABLE abiliator_options ADD COLUMN new_column01 TEXT NOT NULL DEFAULT 'migrated from version 1'";
}
case 2:
{
sql = "ALTER TABLE abiliator_options ADD COLUMN new_column02 TEXT NOT NULL DEFAULT 'migrated from version 2'";
}
case 3:
{
sql = "ALTER TABLE abiliator_options ADD COLUMN new_column03 TEXT NOT NULL DEFAULT 'migrated from version 3'";
}
case 4:
{
sql = "ALTER TABLE abiliator_options ADD COLUMN new_column04 TEXT NOT NULL DEFAULT 'migrated from version 4'";
}
case 5:
{
sql = "ALTER TABLE abiliator_options ADD COLUMN new_column05 TEXT NOT NULL DEFAULT 'migrated from version 5'";
}
}


sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK)
{
if (sqlite3_step(selectstmt) == SQLITE_DONE)
{
NSLog(@"Alter statement successful");
[self setDatabaseSchemaVersion];
}
else {

NSLog(@"Failed to alter the table with message '%s'.", sqlite3_errmsg(database));
}
}
else {
NSLog(@"Failed to prepare the statement with message '%s'.", sqlite3_errmsg(database));

}
sqlite3_finalize(selectstmt);

第一个警告是对于所有 sql 变量分配,存储到“sql”的值永远不会被读取,除了开关中的最后一个(情况 5)。情况 5 不会导致警告。

第二个警告是函数调用参数是未初始化的值。这是为了if(sqlite3_prepare_v2(数据库, sql, -1, &selectstmt, NULL) == SQLITE_OK)声明。

预先感谢您的提示。

最佳答案

你错过了每个案例之后的休息时间。仅使用最后一个分配。

关于iphone - 存储到 'var name' 的值永远不会被读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9194697/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com