Home Help Center

Adding new members to struct that is passed over ICE?

aondraaondra Member John SmithOrganization: PersonalProject: Graphics
I have a struct that is passed between our receiver and sender quite often and I would like to add two new data members to it.

I can't seem to find anything in the documentation on how this will effect backwards compatibility, so I'm wondering what exactly would happen if we connect a receiver using this new struct to a sender who still uses the old struct (or visa versa)?

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Ashton,

    Welcome to the forum.

    Most changes to data members would break backward compatibility: adding a member, removing a member, and changing the type or declaration order of a member. The Ice encoding does not include type metadata therefore the receiver would have no way of knowing about these changes.

    We added support for optional values in Ice 3.5 to ease this versioning problem. However, even this wouldn't help in your case because structures do not support optional members.

    One possible workaround would be to add an entirely new operation that accepts a new type. Adding a new operation to an interface doesn't break backward compatibility, but it does mean that callers are able to handle the situation where this new operation is not supported by all targets.

    Regards,
    Mark
  • aondraaondra Member John SmithOrganization: PersonalProject: Graphics
    Hi Mes,

    Thanks for the quick response!

    Using a new operation which includes a new version of our struct (Struct2.0) was our first idea, so maybe we will explore more down that route.

    Thanks again,

    Ashton
    mes wrote: »
    Hi Ashton,

    Welcome to the forum.

    Most changes to data members would break backward compatibility: adding a member, removing a member, and changing the type or declaration order of a member. The Ice encoding does not include type metadata therefore the receiver would have no way of knowing about these changes.

    We added support for optional values in Ice 3.5 to ease this versioning problem. However, even this wouldn't help in your case because structures do not support optional members.

    One possible workaround would be to add an entirely new operation that accepts a new type. Adding a new operation to an interface doesn't break backward compatibility, but it does mean that callers are able to handle the situation where this new operation is not supported by all targets.

    Regards,
    Mark
Sign In or Register to comment.