如果Boost库取决于结构成员的路线? [英] Should boost library be dependent on structure member alignments?

查看:121
本文介绍了如果Boost库取决于结构成员的路线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了,<一个href="http://stackoverflow.com/questions/2704732/how-do-i-compile-boost-using-cdecl-calling-convention/2709581#2709581">hard这样,至少的boost :: program_options 是依赖于编译器配置结构成员对齐的。

I found, the hard way, that at least boost::program_options is dependent of the compiler configured structure member alignment.

如果您使用默认设置打造提升,并使用4个字节的项目联系起来对齐( / ZP4 )将在运行时失败(MADE WITH program_options最小测试) 。加速会产生一个断言表示可能不好调用约定,但真正的原因是结构成员对齐方式。

If you build boost using default settings and link it with a project using 4 bytes alignment (/Zp4) it will fail at runtime (made a minimal test with program_options). Boost will generate an assert indicating a possible bad calling convention but the real reason is the structure member alignment.

有没有什么办法prevent呢?如果校准使得code不兼容不应该将其纳入库命名?

Is there any way to prevent this? If the alignment makes the code incompatible shouldn't this be included in library naming?

推荐答案

您需要确保您的程序和你链接库具有相同的ABI。

You need to ensure that your program and the libraries you link with have the same ABI.

编译器开关,可以改变C ++类和函数的ABI可能会太大,因此显然是一个问题,命名3000多个组合的数量。

The number of compiler switches that can alter the ABI of C++ classes and functions could be too large so it is clearly a problem to name more than 3000 combinations.

您可以看看这里更详细的理由。

You could take a look here for a more detailed rationale.

这篇关于如果Boost库取决于结构成员的路线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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