I have some experience writing C libraries but I've never read any formal documents describing good practices while writing such libraries. My question pertains around mainly 2 topics:
The main thing about binary compatibility that I can see from my research is that I can make libraries binary compatible by using the pImpl idiom but changing the structure / adding new data members etc can affect it's binary compatibility even while using pImpl. Also, is there a way to add new methods / functions to a library without actually breaking the binary compatibility? I am assuming adding these things would change the size, layout of the library thus breaking compatibility.
Is there a tool to check binary compatibility?
I have already read these articles. Are there any other docs I can peruse?
http://en.wikipedia.org/wiki/Opaque_pointer
http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++
Also, are there articles which describe ownership issues of memory in the context of designing library interfaces. What are the general conventions? Who owns memory, for how long, who is responsible for deallocating memory etc?
The key compatibility issues are:
#define
/enum
constant values in shared headersSo the best list of guidelines I can give is:
dup
versus dup2
or wait
versus waitpid
).struct
types).#define
/enum
constants. Only add new constants with previously-unused values.If you follow these guidelines, I think you're at least 95% covered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With