Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will adding/removing a function static variable break binary compatibility?

Tags:

c++

I have to maintain binary compatibility for this C++ library that I'm working on.

Currently, I have something along these lines

class Foo
{
    void Bar()
    {
        static bool flag = true;
    }
}

Will removing flag break binary compatibility of Foo?

Aside My compiler presently is VC7.1 if that matters.

like image 511
Daniel A. White Avatar asked Oct 21 '22 14:10

Daniel A. White


1 Answers

The static variable is not part of the function's interface, so it won't affect binary compatibility. You should be aware, none the less, that if the function is really that simple, it might have been inlined in which case unless you recompile all users you will be breaking the ODR.

Simple advice: recompile if at all possible. Make sure that it was not inlined in the original code if not possible.

like image 135
David Rodríguez - dribeas Avatar answered Nov 15 '22 04:11

David Rodríguez - dribeas