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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8ecbc35ea893182f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 25 Feb 2008 20:36:15 -0600 From: "Steve" Newsgroups: comp.lang.ada References: Subject: Re: Interfacing to C: big structures Date: Mon, 25 Feb 2008 18:36:35 -0800 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Original Message-ID: X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 24.20.111.206 X-Trace: sv3-l4ZQlRWbdE1dIEd6B28ug8uUwxhUKjrkrOdZWLYZdUUSSUXpat3aJ133cuV0hfg1fjQZSBQ3IdUYblT!gDjn8LpcUdQUb0mYjiJGRnTaYN4nUFp98cmxALvgXIqHCZo7ieAaez532VlPOBdCvO9wMmNtWTOZ!iXjnChiMC3TjzkLV5eF+X0U+/t3gXw== 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.37 Xref: g2news1.google.com comp.lang.ada:20073 Date: 2008-02-25T18:36:35-08:00 List-Id: "Maciej Sobczak" wrote in message news:c48dc7da-6f04-4f0f-9a8f-e0acc371ee3c@o10g2000hsf.googlegroups.com... > Hi, > > Consider the C API that contains some structure S and a couple of > functions that operate on the state that is stored in the Struct. A > typical usage in C might be: > > struct S s; > > init(&s); > foo(&s); > bar(&s); > baz(&s); > > Above, s is created with automatic storage duration. > > How to interface to this from Ada? I see two options: I don't understand what you mean by "How to interface to this from Ada?": Do you want to be able to perform additional operations on struct S using Ada code? swizzle(&s); Where "swizzle" is an Ada procedure? Or are you asking for something different? Regards, Steve (The Duck) > > 1. Write a simple wrapper that will create S on the heap and use the > pointer everywhere. This is easy, but imposes the use of dynamic > memory, which for some reasons I might want to avoid. > 2. Create an Ada array of basic storage units of "appropriate size" > and pass its address to the C functions. The advantage of this > solution is that it does not impose any particular memory management > scheme, but the disadvantage is that it is potentially non-portable > (how to get the "appropriate size"?). > > Would you suggest some other solution? > > -- > Maciej Sobczak * www.msobczak.com * www.inspirel.com