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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1b5a1e8589d6a2eb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!tudelft.nl!transit0.news.tiscali.nl!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mail Newsgroups: comp.lang.ada Subject: Re: combine Ada with MS VS C++ References: <1110978291.469762.247330@g14g2000cwa.googlegroups.com> <1110984799.156059.248460@z14g2000cwz.googlegroups.com> From: Ludovic Brenta Date: Wed, 16 Mar 2005 22:44:42 +0100 Message-ID: <87hdjb5kqd.fsf@insalien.org> User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:25t++bGtv9y5wKmLGe8gsRYh+q8= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tiscali bv NNTP-Posting-Date: 16 Mar 2005 22:44:33 CET NNTP-Posting-Host: 83.134.237.136 X-Trace: 1111009473 dreader2.news.tiscali.nl 44079 83.134.237.136:34375 X-Complaints-To: abuse@tiscali.nl Xref: g2news1.google.com comp.lang.ada:9520 Date: 2005-03-16T22:44:33+01:00 List-Id: 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.