PDA

View Full Version : sqlite3 build errors in cocoa app




dca1367
Apr 20, 2009, 05:54 PM
Hello,

I'm new to programming with Xcode, so hopefully I'm posting the correct place.

I'm trying to write a Cocoa app that can query an sqlite3 database backend. I'm trying to declare the following variable:

sqlite3_stmt res;

so I can get a result set back from an SQL select statement. But, when I try to build the app, I get the following error:

error: storage size of 'res' isn't known.

I am importing sqlite3.h, and there are some other sqlite3 related functions and data types that are compiling properly, so I'm not sure why there's a problem with this declaration. I've also tried writing a simple C program making use of the sqlite3_stmt data type, and get the same error when using gcc to compile it.

Can anybody tell me why I'm getting the error?

Thanks



Gruffalo
Apr 24, 2009, 01:51 AM
Hello,

I'm new to programming with Xcode, so hopefully I'm posting the correct place.

I'm trying to write a Cocoa app that can query an sqlite3 database backend. I'm trying to declare the following variable:

sqlite3_stmt res;

so I can get a result set back from an SQL select statement. But, when I try to build the app, I get the following error:

error: storage size of 'res' isn't known.

I am importing sqlite3.h, and there are some other sqlite3 related functions and data types that are compiling properly, so I'm not sure why there's a problem with this declaration. I've also tried writing a simple C program making use of the sqlite3_stmt data type, and get the same error when using gcc to compile it.

Can anybody tell me why I'm getting the error?

Thanks

Yes. sqlite_stmt is an 'opaque' structure, so the compiler doesn't know what size it is. You need to declare res as a pointer type. If you look at the function prototype for sqlite3_prepare(), you will see it expects a sqlite_stmt**.

If you are doing anything with sqlite, I would thoroughly recommend the Apress sqlite book (http://www.apress.com/book/view/9781590596739). As an sql novice I found it really useful reference. There is a set of examples you can download from the same site which you might find useful even if you don't buy the book.