|
From: Jeremy F. <je...@go...> - 2005-03-28 17:30:28
|
Julian Seward wrote:
>How does having a struct as part of the interface make it fragile?
>I am thinking of a very simple struct which contains only function
>pointers; no other data.
>
>If you are really worried about version mismatches in the struct,
>make the first field (viz, offset 0) be an int which carries a
>version identifier. Then we can safely say
>
> "if (struct->version != ...) barf()"
>
>This at least allows detection of ABI-level mismatches at startup
>time, providing the version number is bumped each time the API changes.
>
>
The trouble with this is that you break the ABI with every function you
add to the interface, even if it doesn't affect the semantics of any
other function, and most tools don't care about it. That's what is
fragile - you break the interface very easily. If you were to have a
registration function per tool entrypoint, it means you can add new
entrypoints without breaking the binaries of any existing tool. That
way you can reserve interface version numbers to mean semantic changes
to the interface.
J
|