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,c370342fe303517b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Sat, 03 Feb 2007 10:15:34 -0600 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: C Interface example References: <1170516037.435847.326440@p10g2000cwp.googlegroups.com> Date: Sat, 03 Feb 2007 17:15:32 +0100 Message-ID: <87irejmd3v.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:sCT38Zy2v+2dkGrm155EyWijX2g= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 62.235.246.78 X-Trace: sv3-PPxQM8cT+WS6kgDk6I9rhdXRn9C9logJp1A8fWdUYEZpdlHafULfUsQhqRE5IDY3kNKNFJWvGWBqg4o!TAFoIG1ZR6GyRhiG2l1+56VBSW0GRP+k+11qg835VT2sYJ7dYbBCWswMkUxTclYl/05vM3PXdQ== X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:8878 Date: 2007-02-03T17:15:32+01:00 List-Id: artifact.one writes: > #ifndef VECTOR_H > #define VECTOR_H > > float *vec_addNf(float *, float *, unsigned int); > > #endif package Vec is type Array_Of_Floats is array (Natural range <>) of Float; function Add (VA : access Array_Of_Floats; VB : in Array_Of_Floats; Length : in Natural) return access Array_Of_Floats; -- Ada 2005 required here pragma Import (C, Add, "vec_addNf"); end Vec; but all calls to Add will have to do something with the value returned. Looking at the body of vec_addNf, I see that the returned value is useless, since the caller obviously already knows the address of VA. Taking advantage of that fact, we can instead declare a procedure: package Vec is type Array_Of_Floats is array (Natural range <>) of Float; procedure Add (VA : in out Array_Of_Floats; VB : in Array_Of_Floats; Length : in Natural); pragma Import (C, Add, "vec_addNf"); end Vec; HTH -- Ludovic Brenta.