netheril96 / StaticJSON

Fast, direct and static typed parsing of JSON with C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RapidJson double inclusion

ramtaneja opened this issue · comments

Hi,

In my project I have a confusing scenario.

There are two modules, module 1 and module 2, module 1 has a older version of RAPIDJSON and module 2 uses a new one,

module 2 has some header inclusions from module 1 which also includes rapidjson header files in return,
so eventually module 2 is having inclusion of both the version d of rapid json.

I though of using a different namespace and also noticed there is easy provision provided by rapid json to do so,

As an experiment I had put a new namespace in the rapidjson.h for module 2 and it works excepts the macros defined in the headers. One example is the RAPIDJSON_PARSE_ERROR macro. This macro had a different set of arguments in headers from module 1 whereas in module 2 headers, it has 3 arguments. Similarly there are few other macros. I guess macros don’t come under the namespace and hence we had to replace the conflicting macros (even with new namespace) by prefixing it with <module 2>_ in all the new RapidJSON headers.

I have checked with module 1 team and they are not in a position to update to new rapidjson.

I do understand that module 2 should not have included hearers from module 1, but currently we have no other solution for this.

Can someone suggest a good solution for this...?

Can't you just do a Find/Replace to change the name of macros?

yes that works, as mentioned in my above message that I prefixed them with "module2_", but that not the ideal solution as over the time another module3 may want to use it, and also its a pain whenever we want to update the rapid json library

Why do you need to use both versions of RapidJSON?

ideally one should not, but the current structure of project is like this. module 1 was written long back using previous version of RapidJSON, module 2 is under progress and I prefer use the latest version of RapidJSON and keep on updating overtime as and when needed.

Does this have anything to do with StaticJSON?

no, this is in general with RapidJSON, Ill close the issue from here