[odb-users] Include of SQLite files and ODB compiler
boris at codesynthesis.com
Tue Nov 25 02:06:47 EST 2014
Erez Pics <picserez at gmail.com> writes:
> [Switched to plain text client, hope it helps]
Yes, much, much, better. Thank you.
> I used ifndef to make the ODB compiler ignore these includes:
> #ifndef ODB_COMPILER
> #include <odb/sqlite/database.hxx>
> #include <odb/sqlite/connection.hxx>
> #include <odb/sqlite/transaction.hxx>
> #endif // ODB_COMPILER
> Which indeed fixed the error and cause another one, because we are
> passing odb::sqlite::database object in our code, it does not know the
> sqlite namespace:
> error: 'sqlite' is not a member of 'odb'
> How would you recommend to resolve this problem ?
While you cannot include most libodb-sqlite headers into headers that
you compile with the ODB compiler, there is an exception: forward.hxx
which forward-declares odb::sqlite::database besides other things. So
the way I would suggest you structure your header/source is as follows:
void do_it (odb::sqlite::database&);
void object::do_it (odb::sqlite::database& db)
The idea here is to only use/pass references/pointers to database in
the header for which a forward-declaration is sufficient. In the source
file, howevere, you include <odb/sqlite/database.hxx> and can call
database operations, etc.
More information about the odb-users