Building Compatible Libraries

P

Peter Olcott

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?
 
N

Noah Roberts

Peter said:
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.
 
G

Gianni Mariani

Peter said:
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?

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.
 
I

Ian Collins

Peter said:
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?
Probably the only safe way is to keep types opaque and provide the
public interface as extern "C" functions.
 
P

Peter Olcott

Ian Collins said:
Probably the only safe way is to keep types opaque and provide the
public interface as extern "C" functions.

That is what I was thinking. This eliminates alignment differences and
differences in the derivation of the underlying naming conventions.
 
N

Noah Roberts

Peter said:
That is what I was thinking. This eliminates alignment differences and
differences in the derivation of the underlying naming conventions.

Oh, I think you're looking for specs like Corba or COM.
 
P

Peter Olcott

Noah Roberts said:
Oh, I think you're looking for specs like Corba or COM.

For my purposes the prior suggestion will probably be optimal. I always try to
go with the simplest possible solution that completely solves the problem. Since
I am interfacing between C++ and a language following to "C" calling
conventions, the prior answer should work the best, and be entirely sufficient
for my needs.
 
N

Noah Roberts

Peter said:
For my purposes the prior suggestion will probably be optimal. I always try to
go with the simplest possible solution that completely solves the problem. Since
I am interfacing between C++ and a language following to "C" calling
conventions, the prior answer should work the best, and be entirely sufficient
for my needs.

I would at least look at those options and see if they meet your needs.
I've seen a lot of rather poor wheel "innovations".
 
P

Peter Olcott

Noah Roberts said:
I would at least look at those options and see if they meet your needs.
I've seen a lot of rather poor wheel "innovations".

I am extensively looking at COM for another purpose. For this purpose I need
none of the baggage of COM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top