Reputation:
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);
}
};
Upvotes: 0
Views: 377
Reputation: 20257
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 :-)
Upvotes: 1
Reputation:
You are not supposed to create objects of type sqlite3, only pointers. Remove the line:
sqlite3 db;
and everything should be ok.
Upvotes: 1