tags:

views:

92

answers:

4

Any examples demonstrating where source compatibility is broken yet binary compatibility is maintained is welcome.

A: 

Yes, source incompatibility implies binary incompatibility. If the signatures have changed in the source code, the signatures will change in the resulting binary and, hence, the resulting binaries will be incompatible.

Michael Aaron Safyan
What do you mean by signatures?
Bastien Léonard
I don't think this is true: if you change the name of something which later gets erased, then the name doesn't matter in the resulting binary, but it *does* matter in the source code. Ergo: API incompatible but ABI compatible. I'm thinking names of macros or constants, or something like that.
Jörg W Mittag
@Bastien Leonard, I was thinking of the names, number of parameters, and parameter types of functions.
Michael Aaron Safyan
A: 

Different versions of static-linked libraries on various machines might result in a binary compiled on machine A working properly on machine B but attempts to compile it from source on machine B failing. But aside from that, source incompatibility generally implies binary incompatibility.

Amber
A: 

Imagine the type of a function parameter changes without the actual size or underlying type changing (say, from one enum to another or from long to int). That'll break source code because of the type check but may not affect the binary compatibility. (Depends on the exact environment -- .NET will be annoyed, but C/C++ won't.)

Promit
+4  A: 

Old version:

struct inner {
  int bar;
}

struct foo {
  struct inner i;
};

void quux(struct foo *p);

New version:

struct inner2 {
  int bar;
};

struct foo {
  struct inner2 i;
};

void quux(struct foo *p);

Broken code:

struct foo x;
struct inner *i = &x.i;
i->bar = 42;
quux(&x);

Since the only difference is the name of the struct, and the inner struct's type name is erased during compilation, there's no binary incompatibility.

bdonlan