为什么要二进制兼容? [英] Why binary compatibility?

查看:160
本文介绍了为什么要二进制兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习PIMPL习语.它的优点之一是二进制兼容性.我想知道二进制兼容性的优点是什么.谢谢!

I am learning PIMPL idiom. One of its advantage is binary compatibility. I am wondering what the advantages of binary compatibility are. Thanks!

推荐答案

它避免了脆弱的二进制接口问题.它是这样的:

It avoids the Fragile Binary Interface Problem. It goes like this:

  1. 程序使用库.

  1. Program uses library.

用户升级库.升级会更改库的二进制接口中的某些内容.

User upgrades library. Upgrade changes something in the library's binary interface.

程序直到重新编译后才起作用,因为它是基于旧的二进制接口构建的.

Program now doesn't work until it is recompiled because it was built to the old binary interface.

PIMPL习惯用法的优点之一是,它使您可以将通常是类的公共接口一部分的内容移动到其私有接口(实际上是私有类的接口)中.您可以在不破坏二进制兼容性的情况下更改私有接口.

One of the advantages of the PIMPL idiom is that it allows you to move things that would normally be part of the public interface of a class into its private interface (in fact, into the interface of a private class). You can change the private interface without breaking binary compatibility.

这篇关于为什么要二进制兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆