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,e289b5ceae0f39c3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-21 14:07:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newspeer.monmouth.com!newsfeed.mathworks.com!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc03.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Binding to C References: X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 12.234.13.56 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc03 1058821672 12.234.13.56 (Mon, 21 Jul 2003 21:07:52 GMT) NNTP-Posting-Date: Mon, 21 Jul 2003 21:07:52 GMT Organization: Comcast Online Date: Mon, 21 Jul 2003 21:07:52 GMT Xref: archiver1.google.com comp.lang.ada:40585 Date: 2003-07-21T21:07:52+00:00 List-Id: >Also does anyone have any advice in general mapping to C. Look at some of the Windows binding source code at www.adapower.com >For the jpeg_error_mgr struct, I mapped ptrs to functions to System.Address >and made the struct a record. Will this work, or will the corresponding >type of the struct have to be a System.Address? You almost never need a System.Address. Use access types. > type Jpeg_Error_Mgr is record > Error_Exit : System.Address; -- addr of a handler > Emit_Message : System.Address; > ... Instead: type Error_Exit_Ptr is access procedure (cinfo : access Decompress_Cinfo_Type); pragma Convention(C, Error_Exit_Ptr); type Emit_Message_Ptr is access procedure (cinfo : access Decompress_Cinfo_Type; msg_level: Interfaces.C.Int); pragma Convention(C, Emit_Message_Ptr); ... procedure error_exit(cinfo : access Decompress_Cinfo_Type); pragma Export(C, error_exit); procedure emit_message(cinfo : access Decompress_Cinfo_Type; msg_level: Interfaces.C.Int); pragma Export(C, Emit_Message); ... type Jpeg_Error_Mgr is record P_Error_Exit: Error_Exit_Ptr; -- will be set := error_exit'access; P_Emit_Message: Emit_Message_Ptr; -- will be set := emit_message'access; etc.