3

I'm writing a C++ program that uses SQLite for database. For this line of code;

void testRun()
{
    // some code here

    sqlite3_stmt stmt;

    // some code here too
}

I get the following error;

error: aggregate 'sqlite3_stmt stmt' has incomplete type and cannot be defined
     sqlite3_stmt stmt;
                  ^

I'm using the amalgamated SQLite source code and have "sqlite3.h" included. What exactly causes this error and how can it be solved? I'm on Windows 7 64bit, using MinGW_64.

Amani
  • 16,245
  • 29
  • 103
  • 153
  • I never used sqlite directly from the C library, but I suppose that its types aren't meant to be instantiated directly, but instead you have to keep only opaque pointers to them (like you use `FILE *`). – Matteo Italia Apr 05 '14 at 12:40
  • See http://stackoverflow.com/questions/10978020/compiling-sqlite-for-windows-64-bit – Andre Kirpitch Apr 05 '14 at 12:44

1 Answers1

3

That's an opaque structure known only to the implementation. You can't create an instance of it, but you can create a pointer to one:

sqlite3_stmt* stmt;
sqlite3_prepare(db, "SELECT...", -1, &stmt, 0);
John Zwinck
  • 239,568
  • 38
  • 324
  • 436