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

Sean Clarke sean.clarke at sec-consulting.co.uk
Sun Sep 13 11:20:41 EDT 2015


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


More information about the odb-users mailing list