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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d31a17870ca7e7e8,start X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g37g2000prf.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Interfacing to C: API with macros Date: Tue, 12 Jun 2007 13:17:29 -0700 Organization: http://groups.google.com Message-ID: <1181679449.352274.217590@g37g2000prf.googlegroups.com> NNTP-Posting-Host: 85.3.208.3 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1181679449 11204 127.0.0.1 (12 Jun 2007 20:17:29 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 12 Jun 2007 20:17:29 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g37g2000prf.googlegroups.com; posting-host=85.3.208.3; posting-account=Ch8E9Q0AAAA7lJxCsphg7hBNIsMsP4AE Xref: g2news1.google.com comp.lang.ada:16172 Date: 2007-06-12T13:17:29-07:00 List-Id: Yet Another Problem (YAP): consider a C function that is defined together with some helper macros. Motivating example: select(2) system call, with its FD_XXX helper macros. (it is unspecified whether FD_XXX helpers are macros or functions, but we can assume the worst) There is no way to pragma Import(C, FD_SET) and the binary layout of fd_set data structure is not specified, so we cannot fake it with Ada. Again, the straightforward solution: thin wrapper in C, that itself is simple enough to be easily imported by Ada code. Again: is this THE solution? Looks like in order to write any nontrivial system software the poor Ada programmer has to start with an awful lots of wrappers - where is maintainability and productivity when you need them? ;-) -- Maciej Sobczak http://www.msobczak.com/