Re: [sqlite] Resolving some compiler warnings when closing db

2009-02-03 Thread Billy Gray
Ah, good thinking.

The Apple-supplied sqlite3.h in Mac OS X (/usr/include/sqlite3.h) doesn't
actually declare it (wtf?) -- although I do have it in
/usr/local/include/sqlite3.h), and I'm statically linking against my own
build. Which I guess is why it builds just fine. Getting the search paths to
cooperate correctly in XCode is a bit of a nightmare.

Thanks!

Billy

On Tue, Feb 3, 2009 at 11:17 AM, Simon Davies <
simon.james.dav...@googlemail.com> wrote:

> 2009/2/3 Billy Gray :
> > Hi all,
> >
> .
> .
> .
> > #import 
> > ...
> > - (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...)
>
> The compiler is telling you that there is no declaration of
> sqlite3_next_stmt. Have a search in sqlite3.h and see if it is lying.
>
> Supplementary question: are you using a version of sqlite that
> implements sqlite3_next_stmt?
>
> Rgds,
> Simon
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



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


Re: [sqlite] Resolving some compiler warnings when closing db

2009-02-03 Thread Simon Davies
2009/2/3 Billy Gray :
> Hi all,
>
.
.
.
> #import 
> ...
> - (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...)

The compiler is telling you that there is no declaration of
sqlite3_next_stmt. Have a search in sqlite3.h and see if it is lying.

Supplementary question: are you using a version of sqlite that
implements sqlite3_next_stmt?

Rgds,
Simon
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Resolving some compiler warnings when closing db

2009-02-03 Thread Billy Gray
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 
...
- (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