包含在某个编译器上工作的未定义行为函数的库是可移植的吗?

发布于 2025-01-12 01:52:19 字数 1700 浏览 4 评论 0原文

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

メ斷腸人バ 2025-01-19 01:52:19

不要从 C++ 标准中寻找所有答案。

C++ 标准没有定义由不同编译器编译的目标模块链接在一起时的行为。 C++ 标准的管辖范围仅限于其创建者选择遵守 C++ 标准的单个 C++ 实现。

应用程序二进制接口 (ABI) 涵盖了将不同对象模块链接在一起的情况。如果您使用两个都符合相同 ABI 的编译器编译两个函数,并使用符合 ABI 的链接器链接它们,那么它们通常应该一起工作。还有其他细节需要考虑,例如语言中的各种事物如何绑定到 ABI 中的相应事物。例如,一个编译器可能将 long 映射到 ABI 中的某个 32 位整数类型,而另一个编译器可能将 long 映射到某个 64 位整数类型,这将当然,除非做出相应的调整,否则会干扰协同工作的功能。

Do not look to the C++ standard for all your answers.

The C++ standard does not define the behavior when object modules compiled by different compilers are linked together. The jurisdiction of the C++ standard is solely single C++ implementations whose creators choose to conform to the C++ standard.

Linking together different object modules is covered by an application binary interface (ABI). If you compile two functions with two compilers that both conform to the same ABI and link them with a linker that conforms to the ABI, they generally should work together. There are additional details to consider, such as how various things in the language(s) bind to corresponding things in the ABI. For example, one compiler might map long to some 32-bit integer type in the ABI while the other compiler might map long to some 64-bit integer type, and this would of course interfere with the functions working together unless corresponding adjustments were made.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文