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-Thread: 103376,d31a17870ca7e7e8 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.germany.com!newsfeed.utanet.at!geiz-ist-geil.priv.at!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Re: Interfacing to C: API with macros Date: Tue, 12 Jun 2007 20:25:17 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: <1181679449.352274.217590@g37g2000prf.googlegroups.com> NNTP-Posting-Host: belenus.iks-jena.de X-Trace: branwen.iks-jena.de 1181679917 8137 2001:4bd8:0:666:248:54ff:fe12:ee3f (12 Jun 2007 20:25:17 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Tue, 12 Jun 2007 20:25:17 +0000 (UTC) User-Agent: slrn/0.9.8.0 (Linux) Xref: g2news1.google.com comp.lang.ada:16174 Date: 2007-06-12T20:25:17+00:00 List-Id: * Maciej Sobczak wrote: > 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. Have a look at the semantics of those macros, you will notice, that they are a application level language in C hiding the expressivness holes of the language. Now you have a higher level language and you are expected to use it! > 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. We can! We know that fdset_t is a bitarray on all known systems. Therefore type fdset is Array (0..1023) of Boolean; pragma Pack(fdset); and you are done. > 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? ;-) If you try to meet your counterpart at the most evil place, your programm will look as ugly as the counterpart. Use the abstraction of your language! Programm what they mean, not what they code.