boostorg / describe

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

Clang warnings for described internal types #23

Closed ecatmur closed 2 years ago

ecatmur commented 2 years ago

If I describe an enum or class in an unnamed namespace, clang emits warnings, either (if the descriptor is not used)

warning: unused function 'boost_enum_descriptor_fn' [-Wunused-function]

or, if the descriptor is used:

warning: function 'boost_enum_descriptor_fn' is not needed and will not be emitted [-Wunneeded-internal-declaration]

Example: https://godbolt.org/z/qPrdcT5KG

#include <boost/describe.hpp>
namespace {
BOOST_DEFINE_ENUM(E, A);
class S { BOOST_DESCRIBE_CLASS(S, (), (), (), ()); };
}
using namespace boost::describe;
using D = describe_enumerators<E>;
using B = describe_bases<S, mod_any_access>;
using M = describe_members<S, mod_any_access>;

It looks like these can be suppressed with [[maybe_unused]]; I'll submit a PR.

pdimov commented 2 years ago

Thanks.