Hi all,

Forgive me if this has been discussed here already, I tried searching for
the answer and came up empty.

I'm trying to work out a couple of compiler warnings I get when I close my
sqlite3 connection as described in the manual. I know I could just silence
them, but I'm a bit of a stickler for stuff like this. Here's the relevant
code:

#import <sqlite3.h>
...
- (void) closeDb {
    // first loop thru any existing statements and kill'em
    sqlite3_stmt *pStmt;
    while( (pStmt = sqlite3_next_stmt(db, 0)) != 0 ){
        sqlite3_finalize(pStmt);
    }

    int result = sqlite3_close(db);
    if (result != SQLITE_OK) {
        NSAssert1(0, @"Failed to close database, returned error code %d",
result);
    }
    db = nil;
}

This produces two warnings for the sqlite3_next_stmt line:

- Implicit declaration of sqlite3_next_stmt (which is bizarre...)
- Assignment makes pointer from integer without a cast

Obviously, I'm working in Objective-C, I'm justing GNU compiler via Apple's
XCode. I've tried resolving the assignment issue like this, and while it
cures the warning, not sure it's entirely appropriate:

    int next_stmt;
    sqlite3_stmt *pStmt;
    while( (next_stmt = sqlite3_next_stmt(db, 0)) != 0 ){
        pStmt = (sqlite3_stmt *)next_stmt;
        sqlite3_finalize(pStmt);
    }

And as far as the 'implicit declaration' issue, I really have no idea what's
causing that, since the other sqlite3 functions aren't giving me the same
problem.

Anybody else ever have to work this out?

Cheers!

-- 
Billy Gray
wg...@zetetic.net
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to