I am getting linking 2005 errors when using standalone boost:json
in two different .cpp files in my MFC project.
I understand the constraints, but I wonder is there is any change to get rid of it.
The two instances of those classes are not related between them, but both operate with json files.
Is there any unobvious way to bypass this limitation without creating a new class and sharing pointers/references from one object to the other to call each other functions?
The source code may be like this:
classA.cpp:
#include <boost/json/src.hpp>
boost::json::object json;
void classA::writeJson()
{
json["a"] = 1;
}
classB.cpp
#include <boost/json/src.hpp>
boost::json::object json;
void classB::writeJson()
{
json["b"] = 2;
}
main.cpp
#include "classA.h"
#include "classB.h"
int main()
{
classA obj1;
classB obj2;
obj1.writeJson();
obj2.writeJson();
}
I do not include headers for simplicity. Please, remember to activate the standalon preprocessor directive (yes, I know is deprecated, but sadly is a project requirement).