From: "Frank J. Lhota" <NOSPAM.lhota.adarose@verizon.net>
Subject: Re: calling an ada procedure from C++
Date: Tue, 18 Nov 2003 00:32:23 GMT
Date: 2003-11-18T00:32:23+00:00 [thread overview]
Message-ID: <rMdub.47447$bQ3.38402@nwrdny03.gnilink.net> (raw)
In-Reply-To: m38ymezgo4.fsf@insalien.org
"Ludovic Brenta" <ludovic.brenta@insalien.org> 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.
next prev parent reply other threads:[~2003-11-18 0:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-12 15:11 calling an ada procedure from C++ Anthony Moss
2003-11-17 4:04 ` red floyd
2003-11-17 7:37 ` tmoran
2003-11-17 10:38 ` Duncan Sands
2003-11-17 14:32 ` Hyman Rosen
2003-11-17 18:28 ` Frank J. Lhota
2003-11-18 0:03 ` Ludovic Brenta
2003-11-18 0:32 ` Frank J. Lhota [this message]
2003-11-22 5:25 ` Dave Thompson
2003-11-17 21:13 ` sk
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox