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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news4.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Ada equivalent for C-pointer? Date: Sun, 16 Jan 2005 09:36:04 +0100 Organization: None Message-ID: <7107744.J8aUxUzYtP@linux1.krischik.com> References: <41E7F653.2F899F47@alfred-hilscher.de> Reply-To: martin@krischik.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1105865413 02 24361 091rrjSLRmv6SCyN 050116 08:50:13 X-Complaints-To: usenet-abuse@t-online.de X-ID: S15zzZZCgeE2aE2CTVCrj0YZ6OnSSkQze-Z18JfqNOCH84+sDwcTk0 User-Agent: KNode/0.8.0 Xref: g2news1.google.com comp.lang.ada:7841 Date: 2005-01-16T09:36:04+01:00 List-Id: 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. Read: http://en.wikibooks.org/wiki/Programming:Ada:Types:access#C_compatible_pointer > So, you probably want: > > function Wibble (Number: access Interfaces.C.int) return > Interfaces.C.int; pragma Import(C,Wibble,"wibble"); No! you don't want that! You would need aliased data then! Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com