veselink1 / refl-cpp

Static reflection for C++17 (compile-time enumeration, attributes, proxies, overloads, template functions, metaprogramming).
https://veselink1.github.io/refl-cpp/md__introduction.html
MIT License
1.05k stars 76 forks source link

100-item limit for REFL_AUTO #55

Closed rpatters1 closed 2 years ago

rpatters1 commented 2 years ago

EDIT:

I figured out that refl-cpp can already handle >100 items. You just have to use the other syntax:

REFL_TYPE(MyType)
   REFL_FUNC(Func1)
   ...
   REFL_FUNC(Func193)
REFL_END

As far as I can tell, this syntax works identically to REFL_AUTO including support for user-defined properties. So my original enhancement request was moot. I'm leaving the rest of this issue here in case any other lost lamb comes looking for help with it. It would be helpful to call it out in the documentation as an alternative when there are >100 items in the REFL_AUTO list.

(Original text follows.)

=============================

I'm working with a pre-existing class framework that is risky to modify. I am finding myself exceeding or near-exceeding the 100-item limit in REFL-AUTO. Fine, I thought to myself, I'll just expand it to 200 in a fork. But then I hit an absurdly laughable limit in the Visual Studio 2019 compiler. It absolutely cannot and will not handle a macro with more than 127 arguments.

It would be nice if there were a way to continue REFL_AUTO for a class in a subsequent macro. I don't understand the refl-cpp code well enough to suggest a sensible syntax, but I'm thinking something along the lines of

/* fantasy syntax: see edit above. This makes no sense based on that edit, but it was my original post. */

REFL_AUTO
(
   type(mytype, continues()),
   func(func1),
   ...
   func(func99)
)

REFL_CONTINUES
(
   type(mytype),   // plus, ideally, the option to continue again with continues()
   func(func101),
   ...
)
veselink1 commented 2 years ago

See also https://docs.microsoft.com/en-us/cpp/cpp/compiler-limits?view=msvc-160 The REFL_TYPE/REFL_END syntax works around that limitation.

rpatters1 commented 2 years ago

If REFL_TYPE/REFL_END is now the preferred syntax, it might be helpful to update the Doxygen pages to that effect. Or at least mention them as an alternative. What saved me was a random article about it on the internet. At first it seemed like the REFL_AUTO syntax had superseded the other, which is why I started out using it.