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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6b77ce1ba18f9267 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-07 11:01:42 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!opentransit.net!proxad.net!news-hub.cableinet.net!blueyonder!newspeer1-gui.server.ntli.net!ntli.net!news13-win.server.ntlworld.com.POSTED!not-for-mail From: "chris.danx" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-gb, en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Import a type from C References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Inktomi-Trace: pc2-bbrg1-4-cust108.renf.cable.ntl.com 1036695701 24825 80.4.70.108 (7 Nov 2002 19:01:41 GMT) Message-ID: Date: Thu, 07 Nov 2002 19:00:27 +0000 NNTP-Posting-Host: 80.1.224.4 X-Complaints-To: abuse@ntlworld.com X-Trace: news13-win.server.ntlworld.com 1036695702 80.1.224.4 (Thu, 07 Nov 2002 19:01:42 GMT) NNTP-Posting-Date: Thu, 07 Nov 2002 19:01:42 GMT Organization: ntl News Service Xref: archiver1.google.com comp.lang.ada:30551 Date: 2002-11-07T19:00:27+00:00 List-Id: Francisco Santoyo wrote: > Hi > > I have to use a type struct, which is defined in a C library. Anybody > know, > how can I import that type from C to Ada? > > Thanks. As far as I'm aware you can't import a "type", but you can declare an equivalent type and import variables of that type into Ada. i.e. you can't import the type X, only variables of type X. struct myStruct { int x; int y; char *str; }; would go to an Ada record type myStruct is record x : integer; y : integer; str : blah -- haven't done this in a while. end record; The details are a little sketchy as I've been programming in Java for two, maybe three months now (my knowlege of Ada is evaporating :( ), but structs in C rougly correspond to records in Ada, C strings to Char_Ptr, etc. Of course, some of this depends on the compilers involved too, so there's some variation. What I would be inclined to do in the case of Strings would be to convert C strings to proper Ada Strings, if I was going to use them in Ada code and no more in C code (if you need to send them back, you have to consider a tradeoff between the convienance of Ada strings and the conversion between the two forms - which costs time). The lovelace tutorial has some text on interfacing with C, which maybe worth a look (it's a much better description than my pitiful attempt, so you *should* read it to unconfuse yourself after reading my post :) I have a habit of doing stuff like that). There's a link to it from www.adapower.com iirc. hth, Danx -- for personal replies change spamoff to chris