[odb-users] include issues and unknown class errors on many-to-one relationships

MM finjulhich at gmail.com
Sun Sep 13 15:53:54 EDT 2015


On 13 September 2015 at 16:20, Sean Clarke <sean.clarke at sec-consulting.co.uk
> wrote:

> Hi,
>     For some reason I keep getting include issues when I try and set up
> some basic many-to-one relationships- I can get your examples to work
> because they are in the same file, yet mine (when I split across multiple
> headers) seem to get in a bit of a state....
>
> ------------------------------------------------
> Job.hpp
> ------------------------------------------------
> #pragma once
>
> class Job {
> // lots of stuff
>
> #pragma db value_not_null inverse(m_job)
> std::vector<std::weak_ptr<SomeJobItem>> m_job_items;
> };
> ------------------------------------------------
>
> and then in another header file I have:
>
> ------------------------------------------------
> SomeJobItem.hpp
> ------------------------------------------------
> #pragma once
>
> class SomeJobItem {
> // lots of stuff
>
> #pragma db not_null
> std::weak_ptr<Job> m_job;
> };
> ------------------------------------------------
>
> This gives errors that it can't find the class (even though I include the
> headers in each of them)
>
>  error: ‘JSomJobItem’ was not declared in this scope
>  std::vector<std::weak_ptr<SomeJobItem>> m_job_items;
>
> etc.
>
> I can't forward declare the classes as ODB then complains that the type
> maps to a non DB type...
>
> Any ideas on what I am doing wrong on these simple examples?
>
> Regards
> Sean Clarke


I would try to extract the minimal independent example that you can email
here.
It often happened to me that with the extracted example, an obvious error
appeared that I couldn't see in the real code.
Otherwise, a minimal example can help Boris or the list pinpoint a bug in
the compiler, or just a wrong usage of the pragmas.

Rds,


More information about the odb-users mailing list