When do we break binary compatibility

前端 未结 2 1968
无人共我
无人共我 2021-02-04 15:37

I was under the impression that whenever you do one of these:

  • Add a new public virtual method virtual void aMethod();
  • Add a new public non-vi
2条回答
  •  无人及你
    2021-02-04 16:27

    C++ doesn't say.

    Visual Studio generally follows COM rules, allowing you to add virtual methods to the end of your most derived class unless they are overloads.

    Any non-static data member will change the binary layout as well.

    Non-virtual functions don't affect binary compatibility.

    Templates make a huge mess because of name mangling.

    Your best bet to retain binary compatibility is to use both the pimpl idiom and the nvi idiom quite liberally.

提交回复
热议问题