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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c370342fe303517b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!h3g2000cwc.googlegroups.com!not-for-mail From: artifact.one@googlemail.com Newsgroups: comp.lang.ada Subject: Re: C Interface example Date: 3 Feb 2007 10:09:26 -0800 Organization: http://groups.google.com Message-ID: <1170526166.831811.237660@h3g2000cwc.googlegroups.com> References: <1170516037.435847.326440@p10g2000cwp.googlegroups.com> <45c4cae7$1_4@news.bluewin.ch> NNTP-Posting-Host: 81.179.242.178 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1170526172 20018 127.0.0.1 (3 Feb 2007 18:09:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 3 Feb 2007 18:09:32 +0000 (UTC) In-Reply-To: <45c4cae7$1_4@news.bluewin.ch> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20060601 Firefox/2.0 (Ubuntu-edgy),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: h3g2000cwc.googlegroups.com; posting-host=81.179.242.178; posting-account=3t6ROQ0AAABpbovmj4Qol-vmGur4qb-2 Xref: g2news2.google.com comp.lang.ada:8887 Date: 2007-02-03T10:09:26-08:00 List-Id: On Feb 3, 5:48 pm, Gautier wrote: > Looking at your code the most simple and portable way will be not to interface > at all with C! > > package Vectors is > > type Vector is array(Natural range <>) of Float; > > procedure Add(va: in out Vector; vb: in Vector); > > end Vectors; > > package body Vectors is > > procedure Add(va: in out Vector; vb: in Vector) is > begin > for i in va'Range loop > va(i):= va(i) + vb(i); > end loop; > end Add; > > end Vectors; > > Note that most compilers accept the spec and the body (or more!) in the same > file with the name of your choice; GNAT requires vectors.ads and vectors.adb > HTH Hello. Yes this was quite a contrived example because my real version of vec_add() actually calls Altivec, SSE, SSE2 or pure C code depending on detected hardware, which stretches on to about 300 lines. I didn't think anybody would appreciate reading all that just for an example on interfacing... MC