mercredi 6 décembre 2017

Does adding a new member variable to a class affects the binary compatibility?

I have a class called AMFactory in a shared library. This shared library is used by many user applications. Now I want to add a new private member variable to my class. Does this break the binary compatibility? If it breaks then is there a hack for it. In my case I don't want the user applications to be recompiled. Snippet of my class [AMFactory] and its base class[Factory] below.

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_;
};
}
}

Aucun commentaire:

Enregistrer un commentaire