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,7661856b1d8dc0ab X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.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: Thu, 22 Feb 2007 10:18:00 -0600 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Calling Ada from C References: <1172159208.098190.143360@t69g2000cwt.googlegroups.com> Date: Thu, 22 Feb 2007 17:17:59 +0100 Message-ID: <87mz3688ug.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:tgBaYoQdYV8696U4872eu5kdtPE= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 62.235.195.12 X-Trace: sv3-ZCd9qczHf2so2AcsjlSDtXKER2SFe6eY3BAjSGiBJ0BofotYrH+UE3Wkqhw+BBRXZ9SLY00cmqp9HMV!fzZ+q0iplr9pxf/Wf6ByRkIvP/VEtX7p02Dpe2/xw3ByGdZhBn6NBo6PacyYdqkgal/wjORe3g== 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:9417 Date: 2007-02-22T17:17:59+01:00 List-Id: Hannibal Holm writes: > I have a slight problem trying to call an Ada function from a C > function. I need to pass in an unconstrained array to the Ada > function. The problem is how I specify the size. > > This is probably very simple, but I am more or less just getting > started with Ada, comming from a C-background. > > My code yealds warnings like this (when compiled with GNAT): > > foo.ads:50:23: warning: type of argument "Insert_C.Packet" is > unconstrained array > foo.ads:50:23: warning: foreign caller must pass bounds explicitly > > I have been searching a lot in order to figure out what to do about > this, but all the FFI documentation is for calling C-functions from > Ada, and some very simple examples of how to call ada functions that > take primitive arguments (ints, and similar items). > > Anyone who know how to pass in the bounds explicitly? You have three options: - pass two extra parameters, First and Last - pass the length - declare that the lower bound is some fixed "known" value and pass the upper bound (this is subtly different than the above...) -- Ludovic Brenta.