c++的范围Abi Chages

发布于 2025-01-20 15:03:42 字数 457 浏览 3 评论 0原文

我在 C++ 静态库中定义了以下符号:

struct P
{
    int a;
#ifdef D1
    int b;
#endif
};

class IInterface
{
public:
    virtual void bad(int, P) = 0;
    virtual void good(int, std::string) = 0;
};

并且我有链接所述静态库的可执行文件。 IInterface 实现驻留在我的可执行文件中,静态库通过 IInterface 使用我的实现。问题是 D1 在静态库和可执行文件中的定义不同。我想了解这个问题的范围。我想调用 bad() 是个坏主意。但是调用 good() 安全吗? 假设它的Linux环境和GCC被使用。我在哪里可以阅读有关这些内部结构的更多信息?是ELF格式规范吗?

所讨论的 ABI 更改是 P 的大小更改。库和可执行文件的其余部分完全相同。

I have following symbols defined in C++ static library:

struct P
{
    int a;
#ifdef D1
    int b;
#endif
};

class IInterface
{
public:
    virtual void bad(int, P) = 0;
    virtual void good(int, std::string) = 0;
};

And I have executable that links said static library. IInterface implementation resides in my executable and static library uses my implementation through IInterface. Problem is D1 was defined differently in static library and in executable. I want to grasp the scope of this problem. I guess calling bad() is bad idea. But is it safe to call good()?
Let's say its Linux environment and GCC was used. Where can I read more about these internals? Is it ELF format specs?

ABI change in question is the size change of P. All the rest is exactly the same for library and executable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文