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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b28f27d5b835c2e X-Google-Attributes: gid103376,public From: do_while@lo-pan.ridgecrest.ca.us (Do-While Jones) Subject: Re: Pragma Import to C "Accept" function? Date: 1997/02/13 Message-ID: <5dv9kc$3sr@ash.ridgecrest.ca.us>#1/1 X-Deja-AN: 218514151 References: <5ds893$qgf@bs33n.staffs.ac.uk> Organization: RidgeNet - SLIP/PPP Internet, Ridgecrest, CA. (619) 371-3501 Newsgroups: comp.lang.ada Date: 1997-02-13T00:00:00+00:00 List-Id: In article <5ds893$qgf@bs33n.staffs.ac.uk> cm3bcawp@bs47c.staffs.ac.uk (Al Priest) writes: >I'm looking for a "nice" way to interface to the C accept function. Given >it's clash with the reserved word accept, is there a good way to interface >to the function? Currently the only way I can do it is by writing a C >function to interface to the accept, and then interfacing to that in my >Ada program. > >I'm using latest (Jan'97) version of Gnat compiler for Linux in case it >matters. > >Thanks, > >Al >-- >al@priest.com Here's how I do it. (I don't normally use lower case for function names and variable names, but I did here because I was matching the C names.) function accept_connection( socket : in Socket_numbers; addr : in SYSTEM.Address; addrlen : in SYSTEM.Address) return Socket_numbers; pragma Interface (C, accept_connection); pragma Interface_Information (accept_connection, "_accept"); The code above works for Telesoft Telegen 2 on a Sun workstation. To make it run on Verdix on a Silicon Graphic machine I had to change the last pragma to pragma Interface_Name (accept_connection, "accept"); Both versions of this interface have run for years without problems. Do-While Jones -- +--------------------------------+ | Know Ada | | [Ada's Portrait] | | Will Travel | | wire do_while@ridgecrest.ca.us | +--------------------------------+