/
C API Pattern for Binary Compatibility

C API Pattern for Binary Compatibility

This is pattern I observe often in operating system APIs.

This is a problem - say you have a standard which changes. Like IP4 versus IP6 internet addresses.

How as an API designer for an operating system can I make it so my API can support the new extended format but not break existing older applications which aren’t aware of the new extended format?

Well a common way to solve this problem is to use a struct under the hood and then:

  • Code the type of the struct using an short integer at the start of the struct to identify it’s version or type

  • Also give its length.

 

Related content

What is binary API compatibility?
What is binary API compatibility?
More like this
How do we help our customers when the interface of a library changes to a new incompatible one?
How do we help our customers when the interface of a library changes to a new incompatible one?
More like this
Autoconf(iscate)
Autoconf(iscate)
More like this
Defining C Preprocessor constants from the command line
Defining C Preprocessor constants from the command line
More like this
HL7 Delimiter Redefinition
HL7 Delimiter Redefinition
More like this