Will adding new member function into d pointer class definition break binary compatibility?
For example, will the new definition below break binary compatibility compared to the original? (side question, is there a tool that will tell me if a new .so breaks binary compatibility compared to the old .so? If not, how do I check manually?)
Original:
#ifndef __TESTBC_H__
#define __TESTBC_H__
class APrivate;
class A
{
public:
int get() { d->update(); return _d->get(); }
private:
APrivate *_d;
};
class APrivate
{
public:
int get() { return _val; }
void update() { _val = 1; }
private:
int _val;
};
#endif
New:
#ifndef __TESTBC_H__
#define __TESTBC_H__
class APrivate;
class A
{
public:
int get() { _d->update(); return _d->get(); }
private:
APrivate *_d;
};
class APrivate
{
public:
int get() { return _val; }
void update() { _val = 1; multiply(); }
void multiply() { _val = _val * 10; }
private:
int _val;
};
#endif
FYI: I understand d pointer class should be specified in the cc file instead of header. above example is contrived to focus on binary compatibility issue.