Skip to content

Can data be appended to a struct while maintaining backwards compatibility? #240

Answered by mikkelfj
randyK-HH asked this question in Q&A
Discussion options

You must be logged in to vote

No not really, but in some special cases it might accidentally work:
Structs are officially immutable in schema, but fields can be deprecated but still take up space.

Now, if you change the meaning of a field of same size, or repurpose a deprecated field of same size, then it can work but all parties must sort of either agree, or not look at the field at all - in which case access to other fields will be safe.

Now that is not what you ask. So, if you add fields later, at the end of a struct: You can compare this to how this would work in the C programming language: it can be work, but not if you embed the struct in another struct. In that case you must use pointers. The Flatbuffer equival…

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@randyK-HH
Comment options

Answer selected by randyK-HH
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants