c++linuxgccshared-librariesbinary-compatibility

Does changing the order of class private data members breaks ABI


I have a class with number of private data members (some of them static), accessed by virtual and non-virtual member functions. There's no inline functions and no friend classes.

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

Does changing the order of private data members breaks ABI in this case?

class A
{
    string str;
    static const int static_const_number;
    int number; // <--   integer member moved here
    bool b;
    ...
};


Edit
The types are not changed, only the order of the members. No bit flags are used as well. The code is used as shared library, there's no static linking to this code. I'm on Linux and the compilers are gcc-3.4.3 and gcc-4.1


Solution

  • It might, yes, if for no other reason than that the size of A could be different due to differences in the location and number of padding bytes between the data members.