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.9 required=5.0 tests=BAYES_00,FROM_NUMERIC_TLD autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,79957b22065a2921 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!195.92.193.196.MISMATCH!nntp.theplanet.net!inewsm1.nntp.theplanet.net!news.theplanet.net!not-for-mail From: "Makhno" Newsgroups: comp.lang.ada Subject: Re: DLLs with GNAT Date: Sat, 15 Oct 2005 10:50:06 +0100 Message-ID: References: <30bbc1d4243af92eeda1a46dda9b2a1d@localhost.talkaboutprogramming.com> NNTP-Posting-Host: 81.78.94.16 X-Trace: news8.svr.pol.co.uk 1129369908 1589 81.78.94.16 (15 Oct 2005 09:51:48 GMT) NNTP-Posting-Date: 15 Oct 2005 09:51:48 GMT X-Complaints-To: abuse@theplanet.net X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original Xref: g2news1.google.com comp.lang.ada:5687 Date: 2005-10-15T09:51:48+00:00 List-Id: > I've used DLLs i created in C++ and VBA (under excel). > I have not tried anything with Visual Studio.NET It works fine. One thing they don't tell you is that you can get GNAT to print out the alignment of some ADA records as its compiling, though for some reason it seems to occasionally miss records. To link to functions that take records as arguments, you can pass a pointer to an equivalently-aligned C-style struct and call it with the default C-style calling convention. If ada returns a record as the result of a function, you must link to it using the __stdcall convention, and the struct is returned 'as value' to C (rather than as a pointer). Arrays that are dimensioned [1...n] have size n (indexed 0...n-1 in C), whereas arrays that are dimensioned [0...n] have size n+1. Easy to miss this one (could've left work at 7 on Wednesday, but because of this I left at 8).