tags:

views:

158

answers:

2

Hi everyone. I imported sqlite3.c sqlite3.h into my project - and I'm having trouble compiling it.

Errors:

1>c:\...\storage_manager.h(7) : error C2079: 'storage_manager::db' uses undefined struct 'sqlite3'
    1>storage_manager.cpp
    1>c:\...\storage_manager.h(7) : error C2079: 'storage_manager::db' uses undefined struct 'sqlite3'
    1>ui_manager.cpp
    1>c:\...\storage_manager.h(7) : error C2079: 'storage_manager::db' uses undefined struct 'sqlite3'

Code:

#pragma once
#include "sqlite3.h"
class storage_manager
{
    sqlite3 db;
    sqlite3** db_pp;
public:
    void open()
    {
     sqlite3_open("data.db", db_pp);
    }
};
+1  A: 

I just noticed you try to create a stack variable of type sqlite3 called db. That won't work, as sqlite3 is a handle and you can only have a pointer variable. You need then to pass the address of that pointer variable to sqlite3_open.

@Neil Butterworth spotted it a bit earlier than me :-)

lothar
The sqlite3.h file already does this
anon
It still doesn't work.
Maybe you'll try the forward declarations, they work for me (gcc on Linux)
lothar
Pre-defining the structs in an extern "C" doesn't work either.
+1  A: 

You are not supposed to create objects of type sqlite3, only pointers. Remove the line:

 sqlite3 db;

and everything should be ok.

anon