There is a dynamic library, whose exposed structure is being changed, new fields are being added at the end of the structure.
Memory for the structure is allocated from within the library and application doesn't allocate it.But, the application may be accessing members of the structure directly.
In this case is it required for the application to recompile again with the library?
Library is being used on all Operating Systems (Windows, Linux, Solaris, HP-UX etc).
Some libraries such as FFmpeg do something like this. FFmpeg has a struct AVFrame
whose sizeof
must not be used by applications, as new fields may be added with only a minor version bump. The library provides functions to allocate struct AVFrame
; these functions not allow allocating arrays of them. Care must be taken to avoid using an older minor version than the application was linked to; not all shared library mechanisms support minor versions.
I think this is a bit ugly, but if applications do not do the disallowed things it should be OK. A cleaner method is to keep the layout of structs that need to be extended private.