Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dca1367

macrumors newbie
Original poster
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
 
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. 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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.