From: Ludovic Brenta <ludovic.brenta@insalien.org>
Subject: Re: combine Ada with MS VS C++
Date: Wed, 16 Mar 2005 22:44:42 +0100
Date: 2005-03-16T22:44:33+01:00 [thread overview]
Message-ID: <87hdjb5kqd.fsf@insalien.org> (raw)
In-Reply-To: 1110984799.156059.248460@z14g2000cwz.googlegroups.com
writes:
> Thanks,How would you declared this in ada an MS VS C++ for a procedure
> the procedures is as follows in Ada. Vr and Vl are two global double
> variablers in the C++ program.
>
> Ada:
>
> procedure CheckBuffer(vr,vl : in out is Interfaces.C.double);
>
> Do I need to write something special in the *.DEF file?? except from
> EXPORTS CheckBuffer
I don't program on Windows, so I can't help you with the exporting
from Ada. You may need to use all three arguments to pragma Export in
order to get the link name right; this is the platform-dependent part.
So you'd say something like:
procedure Check_Buffer (vr, vl : in out Interfaces.C.double);
pragma Export (Convention => C, Entity => Check_Buffer,
External_Name => "CheckBuffer", -- this is...
Link_Name => "something"); -- ...the hard part
Once you've done this, you would import this procedure into C++ as
follows:
extern "C" void CheckBuffer (double* vr, double* vl);
The "C" is necessary to avoid C++ name mangling by the linker.
Per Ada Reference Manual, B.3(68):
68. (...) an Ada out or in out parameter
of an elementary type T, is passed as a t* argument to a C
function, where t is the C type corresponding to the Ada type
T. In the case of an elementary out or in out parameter, a
pointer to a temporary copy is used to preserve by-copy
semantics.
--
Ludovic Brenta.
next prev parent reply other threads:[~2005-03-16 21:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-16 13:04 combine Ada with MS VS C++ ich_bin_elvis
2005-03-16 14:18 ` Larry Kilgallen
2005-03-16 14:53 ` ich_bin_elvis
2005-03-16 16:42 ` Martin Krischik
2005-04-12 10:18 ` ich_bin_elvis
2005-04-12 14:38 ` ich_bin_elvis
2005-03-16 21:44 ` Ludovic Brenta [this message]
2005-03-16 22:18 ` Randy Brukardt
2005-03-17 3:32 ` David Botton
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox