【发布时间】:2011-02-26 00:34:05
【问题描述】:
我有一个类,其中包含许多私有数据成员(其中一些是静态的),由虚拟和非虚拟成员函数访问。没有内联函数,也没有友元类。
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
};
在这种情况下,更改私有数据成员的顺序是否会破坏 ABI?
class A
{
string str;
static const int static_const_number;
int number; // <-- integer member moved here
bool b;
...
};
编辑
类型没有改变,只有成员的顺序。也没有使用位标志。
该代码用作共享库,没有静态链接到该代码。
我在 Linux 上,编译器是 gcc-3.4.3 和 gcc-4.1
【问题讨论】:
-
请注意,在您的情况下,您需要声明构造函数和析构函数,因为它们都是内联提供的。
-
@Johannes 是的,它们已被声明,只是在描述中错过了它们。但是感谢您的注意,它很有用。
标签: c++ linux gcc shared-libraries binary-compatibility