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,3cc61b675eac7c7a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.189.72 with SMTP id gg8mr8198995pbc.4.1327842650630; Sun, 29 Jan 2012 05:10:50 -0800 (PST) Path: lh20ni237441pbb.0!nntp.google.com!news1.google.com!news.glorb.com!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Ada as glue ? logical approach ? Date: Sun, 29 Jan 2012 13:10:50 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <9e698480-636a-419f-9b50-400b322de8d4@dp8g2000vbb.googlegroups.com> Mime-Version: 1.0 Injection-Date: Sun, 29 Jan 2012 13:10:50 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="DkTdSjxOCm6DqG+Uf7eArg"; logging-data="26173"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YyU+WYuTIh2dUWK73L9+nRUhvZDtlT/8=" User-Agent: Pan/0.134 (Wait for Me; GIT cb32159 master) Cancel-Lock: sha1:TflEdJvwch/7g1bddCO3KB5v2rY= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2012-01-29T13:10:50+00:00 List-Id: On Sat, 28 Jan 2012 20:53:21 -0800, Patrick wrote: > Hi Everyone > > I have been studying ada for sometime now but I have no experience > coding with it. > > It doesn't look like there are all the library bindings i want but I > am wondering if this really matters. > > Someone could write a full binding for a library but could someone also > not just use the import pragma to "grab onto" the existing C library > APIs? > > This would be a bit like ctypes in Python correct ? Are other list > members writing their own 'as needed' partial bindings? Is this a > logical approach? -Patrick In addition to agreeing with the other comments - especially the recommendation to make a "thick binding" to give you an Ada-like interface, rather than exposing the C-like details any more widely than necessary... if you use a recent enough version of GCC, you can compile a C or C++ header file with the -fdump-ada-spec or -fdump-ada-spec-slim options, and it will automatically generate the thin binding (with import pragmas) for you. The -slim version just compiles the header you give it; the fat version compiles the transitive closure (i.e. all the header files it imports too, recursively) The result is not perfect; very good on plain C but it doesn't handle C++ templates very well (last time I looked) but even then, it saves a lot of time. I would implement the Ada binding as a package that uses this, exposing only Ada types and functions to the rest of your code. A very simple example : http://wiki.ada-dk.org/c_bindings_example If you are importing C rather than C++, ignore the bit about saving the header as .hpp. (There is another way to force C vs C++, not covered in the article. Compile a .h file with g++ rather than gcc) See also http://www.adacore.com/2009/02/23/gem-59/ - Brian