Consider the following C++ code:
struct X
{
int a;
int b;
};
X foobar()
{
X x = { 1, 2 };
return x;
}
Now assume this code is put in a shared library, which is used by third-party applications.
My question is: if I add another member at the end of X
(e.g. int c
), and initialize it in foobar()
, will existing applications which call foobar()
break? Note that this is about binary compatibility, not source compatibility.
X
is declared and defined in a header which is used to compile the application.foobar()
is declared in a header but defined in a.cpp
file inside the shared library. Of course, ifX
changes, the application won't be recompiled and so won't "see" that the header changed. Hence the question. – Etienne DechampsX
evolves. It seems that's not the case, so I'll just write it another way. No worries. – Etienne Dechamps