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,ac6f6c30c45f808a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!t-online.de!news.zanker.org!border2.nntp.ams.giganews.com!nntp.giganews.com!feeder2.news.jippii.net!reader1.news.jippii.net!53ab2750!not-for-mail Message-ID: <41EA81CC.8090804@nowhere.fi> From: Niklas Holsti Organization: Tidorum Ltd User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020623 Debian/1.0.0-0.woody.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada equivalent for C-pointer? References: <41E7F653.2F899F47@alfred-hilscher.de> <7107744.J8aUxUzYtP@linux1.krischik.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 16 Jan 2005 17:01:32 +0200 NNTP-Posting-Host: 81.17.205.61 X-Complaints-To: newsmaster@saunalahti.com X-Trace: reader1.news.jippii.net 1105887682 81.17.205.61 (Sun, 16 Jan 2005 17:01:22 EET) NNTP-Posting-Date: Sun, 16 Jan 2005 17:01:22 EET Xref: g2news1.google.com comp.lang.ada:7848 Date: 2005-01-16T17:01:32+02:00 List-Id: Martin Krischik wrote: > Pascal Obry wrote: > > >>Nick Roberts writes: >> >> >>>For example, if there is a C function defined thus: >>> >>> int wibble(int *n); >>> >>>then in Ada you can declare: >>> >>> function Wibble (Number: in out Interfaces.C.int); >>> pragma Import(C,Wibble,"wibble"); >>> >>>and it should work. (Obviously, you must link the C functions in >>>somehow.) >> >>I don't think so. Here Number will be passed by value, no? And you also >>need the returned value ;) > > > No all out and in out parameter are passed as pointer when pragma Import(C > is used - thats unless you use C_Pass_By_Copy. I have written quite a lot > of code interfaceing with C. But according to LRM B.3(68), for an "in out" parameter of an *elementary* type (as here) the pointer that is passed to the C function is a pointer to a *temporary copy* of the parameter (here Number), not a pointer to the parameter itself. This may not be what the C function expects. For example, it would not make sense for "wibble" to save the pointer for later use. (Perhaps this detail is explained in the Wiki page that was referenced. For some reason, I couldn't reach that page to read it.) -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .