Dmi*_*kov 9 c++ linux gcc shared-libraries binary-compatibility
我有一个包含多个私有数据成员的类(其中一些是静态的),由虚拟和非虚拟成员函数访问.没有内联函数,也没有朋友类.
class A
{
int number;
string str;
static const int static_const_number;
bool b;
public:
A();
virtual ~A();
public:
// got virtual and non-virtual functions, working with these memebers
virtual void func1();
void func2();
// no inline functions or friends
};
Run Code Online (Sandbox Code Playgroud)
在这种情况下,更改私有数据成员的顺序是否会破坏ABI?
class A
{
string str;
static const int static_const_number;
int number; // <-- integer member moved here
bool b;
...
};
Run Code Online (Sandbox Code Playgroud)
编辑
类型不会更改,只会更改成员的顺序.也没有使用位标志.代码用作共享库,没有静态链接到此代码.我在Linux上,编译器是gcc-3.4.3和gcc-4.1
根据KDE策略/二进制兼容性问题使用C++,如果不打破二进制兼容性,就无法做到这一点.但是,正如他们的免责声明所述,他们在"你不能......"部分提供的一些建议依赖于编译器,因此你可能会摒弃这种变化(虽然不太可能).