boostorg / describe

A C++14 reflection library
https://boost.org/libs/describe
67 stars 24 forks source link

BOOST_DESCRIBE_ENUM fails above 24 enumerators #6

Closed ddevienne closed 3 years ago

ddevienne commented 3 years ago

Started integrating Boost.Describe in my code generator (as discussed on the Boost ML).

Works on all my enums, except the largest with 27 enumerators. If I reduce the described enumerators to 24, then it's OK. (I didn't change the enum, my code would not compile anymore, just omitted a few enumerators in the DESCRIBE macro).

Is there a preprocessor limit that needs to be increased? Aren't native variadic macros unlimited in number of arguments? What's one supposed to do in this case?

No mention to that limit in https://pdimov.github.io/describe/doc/html/describe.html#implementation_limitations

pdimov commented 3 years ago

There is unfortunately a limit of 24 in https://github.com/pdimov/describe/blob/eea288e04961374721020b5454707590815b2fcf/include/boost/describe/detail/pp_for_each.hpp, yes. You're right that it needs to be documented (after being increased appropriately).

ddevienne commented 3 years ago

Since I'm code-generating this, could there be lower-level macros I could use and combine, to not be limited to 24 in the single friendly macro? Something like a BEGIN_ENUM, ADD_ENUM x times, END_ENUM?

pdimov commented 3 years ago

That would be possible too, I suppose. BOOST_DESCRIBE_ENUM_BEGIN(E), BOOST_DESCRIBE_ENUM_IMPL(E, e) x N, BOOST_DESCRIBE_ENUM_END(E). I'm not going to make these part of the documented interface though. :-)

I don't want to make changes while the review is ongoing, though, as judging by past experience reviewers often don't like this, even though the master branch would remain stable.

pdimov commented 3 years ago

The limit is 52 now, and there are _BEGIN, _ENTRY, _END (undocumented) macros.

ddevienne commented 3 years ago

I'm updated to the latest, and all my enums are OK now. No new issues or warnings on VS 2019 or GCC 9.1. Thanks.