构建兼容的库 [英] Building Compatible Libraries

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

问题描述

据我所知,数据对齐不是标准化的事情之一。如果这是真的,那么如何构建库使得一个
供应商的编译器可以直接访问聚合数据类型,例如< struct>

这些类型是使用其他供应商的编译器编译?

From what I understand data alignment is not one of the things that has been
standardized. If this is true, then how are libraries constructed such that one
vendor''s compiler can directly access aggregate data types such as <struct>
where these types were compiled using another vendor''s compiler?

推荐答案



Peter Olcott写道:

Peter Olcott wrote:

据我所知,数据对齐不是标准化的事情之一。如果这是真的,那么如何构建库使得一个
供应商的编译器可以直接访问聚合数据类型,例如< struct>

这些类型是使用其他供应商的编译器编译?
From what I understand data alignment is not one of the things that has been
standardized. If this is true, then how are libraries constructed such that one
vendor''s compiler can directly access aggregate data types such as <struct>
where these types were compiled using another vendor''s compiler?



标准没有提及库。

The standard says nothing about libraries.


Peter Olcott写道:
Peter Olcott wrote:

据我所知,数据对齐不是标准化的事情之一。如果这是真的,那么如何构建库使得一个
供应商的编译器可以直接访问聚合数据类型,例如< struct>

这些类型是使用其他供应商的编译器编译?
From what I understand data alignment is not one of the things that has been
standardized. If this is true, then how are libraries constructed such that one
vendor''s compiler can directly access aggregate data types such as <struct>
where these types were compiled using another vendor''s compiler?



它没有。


这只适用于编译器供应商实施的情况

兼容。


保证结构的一个方面是结构成员放置的顺序是什么,但没有任何关于填充的保证。


说了这么多,有很多实现遵循

相同的方法,以及支持诸如#pragma pack或其他

对齐之类的东西控制机制。

It does not.

This only works if the compiler vendors make their implementations
compatible.

One thing that is guarenteed is the order in which struct members a laid
out, but nothing about padding is guarenteed.

Having said all this, there are alot of implementations that follow the
same methodology as well as supporting things like #pragma pack or other
alignment control mechanisms.




" Noah Roberts" < ro ********** @ gmail.com写信息

新闻:11 ******************** **@i39g2000hsf.googlegr oups.com ...

"Noah Roberts" <ro**********@gmail.comwrote in message
news:11**********************@i39g2000hsf.googlegr oups.com...

>

Peter Olcott写道:
>
Peter Olcott wrote:

>据我所知,数据对齐不是标准化的事情之一。如果这是真的,那么如何构建库以便一个供应商的编译器可以直接访问聚合数据类型,例如< struct>
这些类型是使用其他供应商编译的'的编译器?
>From what I understand data alignment is not one of the things that has been
standardized. If this is true, then how are libraries constructed such that
one
vendor''s compiler can directly access aggregate data types such as <struct>
where these types were compiled using another vendor''s compiler?



标准没有提及库。


The standard says nothing about libraries.



那么,这在现实世界中是如何实现的?

Well then, how is this accomplished in real world practice?


这篇关于构建兼容的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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