[odb-users] error:Unknown pragma;

Boris Kolpackov boris at codesynthesis.com
Thu Aug 16 08:48:50 EDT 2012


Hi,

yb947835908 at gmail.com writes:

> I start to build my own project using odb.
>
> Those files (.hxx,.c.xx,.ixx) are generated successfully, but after that,
> when compiling the project on VS2008, it says
>
> "error :Unknown pragma" in those lines that contain "#pragma db ...."

Normally this is a warning. I think you instructed your VC++ compiler to
treat all warnings as errors. For more information on how to suppress
these warnings/errors, see Section 12.6, "C++ Compiler Warnings" in the
ODB manual.


> also it can't recognise the "db" from text " auto_ptr<database> db (new
> odb::mysql::database (argc, argv));".

I assume you are using the database.hxx file from one of the examples.
If so, then you need to define one of the DATABASE_* macros to select
the database that you would like to use (e.g., DATABASE_SQLITE).
Alternatively, you can remove database.hxx and create the database
directly. For example:

#include <odb/sqlite/database.hxx>

int main (int argc, char* argv[])
{
  odb::sqlite::database db (argc, argv);

  ...
}

Boris



More information about the odb-users mailing list