Search code examples
c++arraysshared-librariesbinary-compatibility

Can Global Arrays in C++ Break Binary Compatibility?


Say a shared library contains the following lines:

const char* const arr[] =
{
  "one",
  "two",
  "three"
};

1) Can an application link to this library and use the symbol "arr"?

2) Is binary compatibility broken if a new element is added to the definition?

3) How about if one of the string literals is changed?

4) Why (not)?

Cheers, Luke


Solution

  • 1) Yes

    2) No

    3) Not a problem

    4) Why would you think otherwise?