From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2c25d9643f05ffd1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-17 16:32:23 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!c03.atl99!chi1.webusenet.com!news.webusenet.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny03.gnilink.net.POSTED!53ab2750!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: <3fb24ce4$1@baen1673807.greenlnk.net> <1069079554.9445@master.nyc.kbcfp.com> Subject: Re: calling an ada procedure from C++ X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: Date: Tue, 18 Nov 2003 00:32:23 GMT NNTP-Posting-Host: 151.203.220.105 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny03.gnilink.net 1069115543 151.203.220.105 (Mon, 17 Nov 2003 19:32:23 EST) NNTP-Posting-Date: Mon, 17 Nov 2003 19:32:23 EST Xref: archiver1.google.com comp.lang.ada:2602 Date: 2003-11-18T00:32:23+00:00 List-Id: "Ludovic Brenta" wrote in message news:m38ymezgo4.fsf@insalien.org... > > I think some compilers will also return small structures in processor > registers. They will neither use the stack not any static memory, if > they can help it. Yes, come to think of it, I have seen that for small structures, and I should have included that in my list of mechanisms. > The basic point remains: how each compiler passes structures between > efunctions is compiler-specific. It is however possible, both in C > and in Ada, to specify the exact bit pattern for a stucture, and thus > to pass the structure back and forth. Even that is not necessarily true for all C compilers! The standard allows a great deal of lattitude in the placement of bit field. According to the 89 standard (I'm not sure about C99), if you define struct Jello { unsigned Flavor : 5 unsigned Servings : 3 }; the compiler is free to implement this by placing Flavor in the high order bits or in the low order bits. This creates a portability problem that has resulted in the underuse of bit fields. > I think the most portable way > would be to pass pointers to the structures (as earlier suggested) but > if the OT uses GNAT (where the compiler handles both C and Ada), there > may be more efficient ways using representation clauses and Pragma > Convention. > > BTW, C++ is a different beast altogether. I would avoid it if > possible, especially if the C++ struct is really a class with methods > and parents or descendants. Better stick with a strictly C struct. The ACT people have provided support for interfacing to C++. In general, the ACT and GNU people are to be congraduated for tackling the issue of multi-language OO programming. > My 2 cents. > > -- > Ludovic Brenta.