danielaparker / jsoncons

A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
https://danielaparker.github.io/jsoncons
Other
717 stars 163 forks source link

warning C4002 on windows with msvs2022 #352

Closed zhmt closed 2 years ago

zhmt commented 2 years ago

Describe the bug my code

JSONCONS_ALL_MEMBER_TRAITS(ezg::g4::gamedesign::GameSettingMap, EquipsMap, EquipsList, .... 50+)
  1. llvm refused to compile, it produced an error: too many arguments for function-like macro invocation

  2. msvs give a warning: warning C4002: too many arguments for function-like macro invocation : JSONCONS_EXPAND_CALL5.

I checked the definition of JSONCONS_EXPAND_CALL5 (in json_traits_macros.hpp ), and I got one line seems like an error: JSONCONS_EXPAND_CALL5(Call, P1, P2, P3, P4, 47, )
I changed it to (delete the last ","): JSONCONS_EXPAND_CALL5(Call, P1, P2, P3, P4, 47)

everything seems ok. Both msvc and llvm compiled silently and sucssesfully.

danielaparker commented 2 years ago

You're right, I guess we haven't had a user with 47+ parameters before, nor a test case with that many parameters. Thanks for reporting this. Would you consider submitting a pull request with this change? (makes it easier to credit the contribution)

zhmt commented 2 years ago

I have submmited a pull request. Happy to contribute.

danielaparker commented 2 years ago

We should keep this open, until we have a release with the fix.

Your PR is merged with master. It also looks like you've reached the limit of the number of parameters supported (50) so I've increased that limit to 70. I've also added a test case that covers the case of 70 parameters.

zhmt commented 2 years ago

Nice work!! I have extended the limit to 54 myself. I should download the newest code from master now. Thank you!

zhmt commented 2 years ago

I have tested . Everything works well.

danielaparker commented 2 years ago

Fixed in 0.168.4