基类改变后重新编译 [英] recompile after base class change

查看:159
本文介绍了基类改变后重新编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


特别是,大多数C ++实现的工作方式意味着
基类大小的变化需要重新编译所有
派生类。

In particular, the way most C++ implementations work implies that a change in the size of a base class requires a recompilation of all derived classes.

此语句来自stroustrup书。
因此,如果基类位于 .so 文件中,我们只是更改了成员函数实现,那么这意味着我们不必重新编译我的程序链接到那个共享对象?

This statement is from stroustrup book. So if base class is in a .so file and we just change a member function implementation, then does it mean that we don't have to recompile my program linked to that shared object?

推荐答案

正式地,如果你不重新编译你违反了单一定义规则,未定义的行为。

Formally, if you don't recompile you're violating the One Definition Rule, and get undefined behavior.

实际上,只要你修改的成员函数没有被内联在任何地方,并且你不改变签名,你可能保留二进制兼容性。在大多数平台上。如果你很幸运,你的平台文档提供了这样的保证。

Practically, as long as the member function you modify hasn't been inlined anywhere, and you aren't changing the signature, you probably retain binary compatibility. On most platforms. If you're lucky, your platform documentation provides such a guarantee.

这篇关于基类改变后重新编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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