open-source-parsers / jsoncpp

A C++ library for interacting with JSON.
Other
8.06k stars 2.63k forks source link

jsoncpp using IStream = std::istream; conflict with WindowsSDK‘s include CommCtrl.h #1497

Closed biepenghaomie closed 10 months ago

biepenghaomie commented 1 year ago

windowsSDK‘s include CommCtrl.h using a struct IStream.jsoncpp using IStream = std::istream; this make conflict.

vassilux commented 10 months ago

Hi, I have the sale issue Is there a solution for ?

biepenghaomie commented 10 months ago

Hi, I have the sale issue Is there a solution for ?

Of cause. You can use other name to replace 'IStream' like 'iStream'. And recompile it. Luckly,jsoncpp use 'IStream' less. So you just pay a little time to change all 'IStream' in jsoncpp source code.

vassilux commented 10 months ago

I find soltion to incldue afxole.h before include jsoncpp.h and it works thanks

BillyDonahue commented 10 months ago

What's the nature of the conflict? If it's macros, then I would recommend isolating the windows header inclusion into a wrapper .cpp file. Only include it off to the side, where it can do less damage to other headers like jsoncpp's headers.

biepenghaomie commented 10 months ago

What's the nature of the conflict? If it's macros, then I would recommend isolating the windows header inclusion into a wrapper .cpp file. Only include it off to the side, where it can do less damage to other headers like jsoncpp's headers.

Windows header CommCtrl.h has a struct declare which name is IStream in the header. So it make the conflict between windows header and jsoncpp.

BillyDonahue commented 10 months ago

But jsoncpp defines a Json::IStream, so it's in the Json namespace. https://github.com/open-source-parsers/jsoncpp/blob/69098a18b9af0c47549d9a271c054d13ca92b006/include/json/config.h#L139

This sounds like the conflict is happening due to the user code breaking the separation between namespaces?

Perhaps the user code has using namespace Json; directives or similar usage? If so, just don't do that.

I would like to see a repro and to see what the compiler's actual error message is.

biepenghaomie commented 10 months ago

But jsoncpp defines a Json::IStream, so it's in the Json namespace.

https://github.com/open-source-parsers/jsoncpp/blob/69098a18b9af0c47549d9a271c054d13ca92b006/include/json/config.h#L139

This sounds like the conflict is happening due to the user code breaking the separation between namespaces?

Perhaps the user code has using namespace Json; directives or similar usage? If so, just don't do that.

I would like to see a repro and to see what the compiler's actual error message is.

You're right. Thanks for your reminder. I overlooked this issue at the time.