veselink1/refl-cpp

Fix warnings for strict variadic macro checks (stronger C++20 enforcement)

Closed this issue · 0 comments

While code-base spring cleaning I noticed that I (unwisely) ignored some refl-cpp variadic macro warnings that prevent gcc|clang compiling with more strict checks enabled (i.e. -Werror).

This shows up already for C++17 with the existing basic refl-cpp's default serialiser example and -pedantic compiler flags.
The corresponding sample output and warnings from running the tests at compiler-explorer:

  • gcc 10.2 or newer produces the following warning:
https://raw.githubusercontent.com/veselink1/refl-cpp/master/include/refl.hpp:4363:31: warning: ISO C++11 requires at least one argument for the "..." in a variadic macro
  • clang 12.0 or newer produce a bit more understandable warning outputs:
https://raw.githubusercontent.com/veselink1/refl-cpp/master/include/refl.hpp:4363:5: warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]
    REFL_DETAIL_PRIMITIVE(char);
    ^
https://raw.githubusercontent.com/veselink1/refl-cpp/master/include/refl.hpp:4359:23: note: expanded from macro 'REFL_DETAIL_PRIMITIVE'
    REFL_TYPE(TypeName) \
                      ^

These checks seem to become more enforced for but also there seems to be a clean solution for C++20 #define FOO(x, ...) bar(x __VA_OPT__(,) __VA_ARGS__) as, for example, discussed in more detail here.
I was wondering whether this could be addressed under the premise that refl-cpp is C++17-based?

Any help would be much appreciated! Thanks in advance!