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,ebad38e7bffe4881 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!wn14feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: C chars_ptr STORAGE_ERROR in Imported function Reply-To: no to spamers (No@email.given.org) References: X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Fri, 22 Aug 2008 18:48:44 GMT NNTP-Posting-Host: 12.65.174.188 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1219430924 12.65.174.188 (Fri, 22 Aug 2008 18:48:44 GMT) NNTP-Posting-Date: Fri, 22 Aug 2008 18:48:44 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:1768 Date: 2008-08-22T18:48:44+00:00 List-Id: Because Char_Prt in "Interfaces.C.Strings" is a private Ada type that C function does not understand. You need to use "Interfaces.C.Pointer" package to build a C Char_Ptr pointer package. And use those functions, etc. A possibility that most teachers may frown about, but it does work is to switch the Ada pointers to "System.Address" and pass to the C functions.. Check out the "Interfaces.C.Extensions.ads" to see how the "void" and "void *" are handled, if the teachers dislike the idea. In , Kim Rostgaard Christensen writes: >Hello there > >I am in progress of binding the pcap c library to ada, it is a part of a >school project. And for that i need a funtion that modifies a parameter >to a function like so: > >char *pcap_lookupdev(char *); > >I have figured out this much: > > function pcap_lookupdev(errbuff : Interfaces.C.Strings.Chars_Ptr) >return Interfaces.C.Strings.Chars_Ptr; > pragma Import (C, pcap_lookupdev, "pcap_lookupdev"); > >This works in the sense that running it as root returns the device >found, but when I run it as normal user I get > >raised STORAGE_ERROR : stack overflow (or erroneous memory access) > >Do I need to declare the buffer and then then pass its c pointer to the >function? > >It is declared like this in a c example: >char errbuf[PCAP_ERRBUF_SIZE]; > >Best >Kim Rostgaard Christensen