-
|
Hi, I have defined the following types within a Namespace (hpp file) namespace JsonParse_ns {
:
class SystemConfig {
std::string title;
...
...
}
}Also created the "from_json" for it (cpp file): namespace JsonParse_ns {
void from_json(const json& j, SystemConfig& s)
{
s.set_title( j.at("Title").get<std::string>() );
....
}
}Both are within the same Namespace, but in different files. The first is in a .hpp file and the implementaiton is in a .cpp file. When I try to compile it, I get the following error: But when I do it with the "NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( SystemConfig, title, ...." macro it works (compiles), even without changing anything on the "from_json" code. The call producing the above error message is the following in the main program: At the moment I am out of ideas what I am doing wrong or miss. But for sure, I do miss something, but what? Any idea? Thanks for any hint! I have done searches for similar issues, but none I have found fixed my issue. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
You need to at least have the declaration of that |
Beta Was this translation helpful? Give feedback.
-
|
@gregmarr Thanks that fixed it! Thanks again! |
Beta Was this translation helpful? Give feedback.
You need to at least have the declaration of that
from_jsonfunction visible everywhere that you want to use it. It is not enough for it to exist somewhere else in the program.