首先,这个weak-vtables的完整警告信息大概长这样:
warning: ‘XXX’ has no out-of-line virtual method definitions; its vtable
will be emitted in every translation unit [-Wweak-vtables]
而这个警告信息的来源一般是这样:
// XXX.h中
class BaseData
{
public:
virtual ~BaseData() = default;
int _base_data = 0;
};
class DerivedDataA final : public BaseData
{
public:
int _derived_data_a = 0;
};
class DerivedDataB final : public BaseData
{
public:
int _derived_data_b = 0;
};