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,d71460587da14d5b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-30 13:51:22 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.stueberl.de!newspeer1-gui.server.ntli.net!ntli.net!newsfep4-glfd.server.ntli.net.POSTED!53ab2750!not-for-mail From: chris User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Importing C structs? References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Wed, 30 Jul 2003 21:52:49 +0100 NNTP-Posting-Host: 81.98.236.164 X-Complaints-To: abuse@ntlworld.com X-Trace: newsfep4-glfd.server.ntli.net 1059598281 81.98.236.164 (Wed, 30 Jul 2003 21:51:21 BST) NNTP-Posting-Date: Wed, 30 Jul 2003 21:51:21 BST Organization: ntl Cablemodem News Service Xref: archiver1.google.com comp.lang.ada:41043 Date: 2003-07-30T21:52:49+01:00 List-Id: Freejack wrote: > I'm finally starting to get an idea(at least I think I am.) on handling > interfacing to C. Really? I don't think I'll ever get the hang of it. > Specifically, would I cast DBTYPE as a seperate record type, and then > provide a seperate function to translate each item into the type expected > by the C struct? Or can import the DBTYPE struct whole hog into my Ada > specification? Make an Ada record corresponding to that type. Map it's fields to things from interfaces.c and other records. Then use pragma Convention(C, DBType); I think! This is from my ongoing work on a libjpeg binding... type Jpeg_Error_Mgr is record Error_Exit : Error_Exit_Handler; Emit_Message : Emit_Message_Handler; Output_Message : Output_Message_Handler; Format_Message : Format_Message_Handler; Reset_Error_Mgr : Reset_Error_Handler; Msg_Code : C.Int; Msg_Parm : System.Address; Trace_Level : C.Int; Num_Warnings : C.Long; Jpeg_Message_Table : Jpeg_Message_TableT; Last_Jpeg_Message : C.Int; Addon_Message_Table : Jpeg_Message_TableT; First_Addon_Message : C.Int; Last_Addon_Message : C.Int; end record; pragma Convention (C, Jpeg_Error_Mgr); HTH, Chris