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,9c274893e2f7e55 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 11 Jan 2005 21:09:42 -0600 From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Ada to C Interface: Passing Pointers Via System.Address References: <8e19522cfe30bb2ccbfe1393fdd6b235@localhost.talkaboutprogramming.com> X-Newsreader: Tom's custom newsreader Message-ID: <5_SdnaIyCMxrCXncRVn-qg@comcast.com> Date: Tue, 11 Jan 2005 21:09:42 -0600 NNTP-Posting-Host: 67.161.24.234 X-Trace: sv3-GFibejNv6u7z6P2CinRk4XhsIFKvDPiTmqtwcP5IqzbFmRnhla9QsTBqyL8/v7pwOdskGylQCQuCy6c!hMjPioHxABvsb/tCgRgzZ8CTlNeIxJCLECXiDb+gxl/Kw3k7vPnysW9TARQe4Q== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net 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.22 Xref: g2news1.google.com comp.lang.ada:7668 Date: 2005-01-11T21:09:42-06:00 List-Id: > My C functions return pointers to data structures (very large structures). > I need to then pass the pointer to the data struct to the Ada code and > back into other C functions. There is no interaction with the data > structure in the Ada code except to pass the pointer from one C function > to another. If the data being passed through Ada is a black box to Ada, why not just declare a type of the appropriate size, eg type C_Thing is range 0 .. 2**32-1; for C_Thing'size use 32; for the Ada code - Ada doesn't need to know if the thing is a pointer, address, segment:offset, whatever. > I have been trying to use the C interface pragma and return the pointers > from C into an Ada System.Address back into the correct pointer type. If you declare something to be an Ada access type, and use a pragma Convention C, the compiler should do the Right Thing. Note that a System.Address might not be the right thing (say if System.Address was a segment:offset while the C pointer was just an offset in a fixed segment). > So far I have not been able to get this to work properly. What kind of error are you getting?