[odb-users] Persisting class for which part of the code is generated at compile time.

Boris Kolpackov boris at codesynthesis.com
Mon Jul 6 12:47:44 EDT 2015

Hi Teererai,

Teererai Marange <selection989 at gmail.com> writes:

>  odb -d mysql  --generate-query --generate-schema --std c++11 resultSet.h
> -x -include -x 8puzzle.c
> [...] 
> baring in mind that the code describing state_t is located in 8puzzle.c is
> there anyway around this and what exactly is the problem?

The normal ODB compilation works this way: the ODB compiler generates
a set of -odb files that include your header file (resultSet.h). In
your case, resultSet.h is incomplete since it needs that 8puzzle.c
"prefix". So my guess is that because this prefix is not included
into the generated header, things break.

Some things I would suggest you consider using:

- Various --*-prologue/epilogue options to include 8puzzle.c at
  the appropriate place in the generated code.

- --odb-prologue instead of -include to include 8puzzle.c in the
  ODB compilation (probably a cleaner way, forgot to mention it
  in my earlier reply).

- The 'definition' pragma to tell the ODB compiler which file it
  should treat as the "definition" of a class.


More information about the odb-users mailing list