Building Compatible Libraries

Discussion in 'C++' started by Peter Olcott, Jan 10, 2007.

  1. Peter Olcott

    Peter Olcott Guest

    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, Jan 10, 2007
    #1
    1. Advertising

  2. Peter Olcott

    Noah Roberts Guest

    Peter Olcott wrote:
    > 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.
    Noah Roberts, Jan 10, 2007
    #2
    1. Advertising

  3. Peter Olcott wrote:
    > 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.
    Gianni Mariani, Jan 10, 2007
    #3
  4. Peter Olcott

    Peter Olcott Guest

    "Noah Roberts" <> wrote in message
    news:...
    >
    > Peter Olcott wrote:
    >> 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?
    Peter Olcott, Jan 10, 2007
    #4
  5. Peter Olcott

    Noah Roberts Guest

    Peter Olcott wrote:
    > "Noah Roberts" <> wrote in message
    > news:...
    > >
    > > Peter Olcott wrote:
    > >> 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?


    The target platform usually has some sort of spec for dynamic
    libraries. There may be other specs to work from as well. In other
    words, it's platform specific and not really guaranteed to work.

    see http://mingw.sourceforge.net/mingwfaq.shtml#faq-msvcdll for example.
    Noah Roberts, Jan 10, 2007
    #5
  6. Peter Olcott

    Ian Collins Guest

    Peter Olcott wrote:
    > 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.

    --
    Ian Collins.
    Ian Collins, Jan 11, 2007
    #6
  7. Peter Olcott

    Peter Olcott Guest

    "Ian Collins" <> wrote in message
    news:...
    > Peter Olcott wrote:
    >> 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.
    >
    > --
    > Ian Collins.


    That is what I was thinking. This eliminates alignment differences and
    differences in the derivation of the underlying naming conventions.
    Peter Olcott, Jan 11, 2007
    #7
  8. Peter Olcott

    Noah Roberts Guest

    Peter Olcott wrote:
    > "Ian Collins" <> wrote in message
    > news:...
    > > Peter Olcott wrote:
    > >> 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.
    > >
    > > --
    > > Ian Collins.

    >
    > 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.
    Noah Roberts, Jan 11, 2007
    #8
  9. Peter Olcott

    Peter Olcott Guest

    "Noah Roberts" <> wrote in message
    news:...
    >
    > Peter Olcott wrote:
    >> "Ian Collins" <> wrote in message
    >> news:...
    >> > Peter Olcott wrote:
    >> >> 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.
    >> >
    >> > --
    >> > Ian Collins.

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


    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.
    Peter Olcott, Jan 11, 2007
    #9
  10. Peter Olcott

    Noah Roberts Guest

    Peter Olcott wrote:
    > "Noah Roberts" <> wrote in message
    > news:...
    > >
    > > Peter Olcott wrote:
    > >> "Ian Collins" <> wrote in message
    > >> news:...
    > >> > Peter Olcott wrote:
    > >> >> 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.
    > >> >
    > >> > --
    > >> > Ian Collins.
    > >>
    > >> 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.
    > >

    >
    > 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".
    Noah Roberts, Jan 11, 2007
    #10
  11. Peter Olcott

    Peter Olcott Guest

    "Noah Roberts" <> wrote in message
    news:...
    >
    > Peter Olcott wrote:
    >> "Noah Roberts" <> wrote in message
    >> news:...
    >> >
    >> > Peter Olcott wrote:
    >> >> "Ian Collins" <> wrote in message
    >> >> news:...
    >> >> > Peter Olcott wrote:
    >> >> >> 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.
    >> >> >
    >> >> > --
    >> >> > Ian Collins.
    >> >>
    >> >> 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.
    >> >

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


    I am extensively looking at COM for another purpose. For this purpose I need
    none of the baggage of COM.
    Peter Olcott, Jan 11, 2007
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Fiske
    Replies:
    0
    Views:
    442
    Daniel Fiske
    Aug 29, 2003
  2. Karsten Wutzke
    Replies:
    21
    Views:
    900
    Roedy Green
    Jun 29, 2007
  3. Sriram Srinivasan
    Replies:
    13
    Views:
    543
    Benjamin Kaplan
    Nov 12, 2009
  4. Harold Hausman
    Replies:
    3
    Views:
    181
    Jano Svitok
    Apr 27, 2007
  5. pantagruel
    Replies:
    0
    Views:
    220
    pantagruel
    Feb 17, 2006
Loading...

Share This Page