在类中添加新的成员变量会影响二进制兼容性



我在共享库中有一个名为amfactory的类。此共享库由许多用户应用程序使用。现在,我想在我的班级中添加一个新的私人成员变量。这会打破二元兼容性吗?如果破裂,那么是否有黑客攻击。就我而言,我不希望重新编译用户应用程序。我的班级的摘要[amfactory]及其下面的基类[工厂]。

namespace CF {
class CF_EXPORT Factory {
 public:
 virtual ~Factory();
 virtual bool registerManager(const std::string &_interface,
                      const Id_t &_id) = 0;
 virtual bool unregisterManager(const std::string &_interface,
                      const Id_t &_id) = 0;
};
}
namespace CF {
namespace AM {
class AMFactory : public CF::Factory {
public:
CF_EXPORT static std::shared_ptr<AMFactory> get();
CF_EXPORT AMFactory();
CF_EXPORT virtual ~AMFactory();
CF_EXPORT bool registerManager(const std::string &_interface,
                      const Id_t &_id);
CF_EXPORT bool unregisterManager(const std::string &_interface,
                      const Id_t &_id);
private:
CF_EXPORT bool registerManager(std::shared_ptr<AMManager>);
CF_EXPORT bool unregisterManager(std::shared_ptr<AMManager>);
static std::shared_ptr<AMFactory> theFactory;
ServicesMap services_;
};
}
}

现在,我想在我的课程中添加一个新的私人成员变量。这会打破二进制兼容性吗?

班级的大小会改变,因此,它会破坏二进制的合理性。

如果它破裂,则有黑客攻击。就我而言,我不希望重新编译用户应用程序。

不是我知道的。这也是(也)为什么我们在开始实施之前专注于设计。

最新更新