comp.lang.ada
 help / color / mirror / Atom feed
From: mgk25@cl.cam.ac.uk (Markus Kuhn)
Subject: Re: Accessing C macro constants from Ada95
Date: 1999/04/13
Date: 1999-04-13T00:00:00+00:00	[thread overview]
Message-ID: <7ev36j$34t$1@pegasus.csx.cam.ac.uk> (raw)
In-Reply-To: 7erp6b$o3f$1@nnrp1.dejanews.com

In Robert Dewar <robert_dewar@my-dejanews.com> writes:
|> Note incidentally that there is nothing to stop a given
|> compiler from implementing:
|> 
|>    X : constant Int;
|>    pragma Import (C, X, "header.h/X");

Yes, that is exactly what I was thinking about. This would simplify the
fully automatic, portable, and comfortable generation of thin C bindings
significantly.

|> On the other hand, trying to pursue the language extension suggestion
|> that Markus makes sounds deadly to me. Just imagine the amount of
|> material that would be required for a stand alone definition of exactly
|> what this Import pragma would do, UGH!

I really do not see the big difficulty here. The specification of this
Ada pragma for importing constants from the C preprocessor macros could
just reference the ISO C standard to get all the required semantics
and terminology readily specified there. Similarly, in an implementation,
compilers like GNAT do already have a full C preprocessor built in,
because they also happen to be full C compilers, so just use the
existing C mechanics to process the *.h files.

I am fully aware of all the existing hacks including c2ada,
writing C wrappers that export macros as C variables, and the option
of copying things manually. Sure, all this is possible, but it is
miles away from what I normally call "portable programming".
Ada alone is a good language for comfortable portable programming,
and so is C alone. However bindings from C to Ada suddenly require
loads of awkward hacks and/or manual intervention that I would
never like to have to explain to students familiar with C in
an Ada programming beginner's class.

You have shown to be a big fan of thin bindings, and I do agree
with you. However I am a bit disappointed about the bureaucratic
effort I have to go through to actually generate a thin C binding,
considering that such a thin binding by definition doesn't add any
functionality or abstraction (otherwise we would call it a thick
binding). I even wonder, why Ada compilers can't generate the equivalent
of thin C bindings fully automatically after I simply name the relevant
C objects that I want to import? Why is it necessary to write wrapper
functions, use tools like c2ada, etc. if all the necessary type
and naming information is practically already available in the C header
files?

Markus

-- 
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org,  WWW: <http://www.cl.cam.ac.uk/~mgk25/>




  reply	other threads:[~1999-04-13  0:00 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-07  0:00 Linux Kernel in Ada. Repost Bruce MacDonald
1999-04-07  0:00 ` Matthew Heaney
1999-04-08  0:00 ` Jeffrey D. Cherry
1999-04-09  0:00   ` Corey Ashford
1999-04-09  0:00     ` Jeffrey D. Cherry
1999-04-09  0:00     ` me
1999-04-09  0:00       ` Tarjei Tj�stheim Jensen
1999-04-09  0:00         ` bill_
1999-04-10  0:00           ` Tarjei Tj�stheim Jensen
1999-04-10  0:00             ` Mich
1999-04-10  0:00               ` Tarjei Tj�stheim Jensen
1999-04-11  0:00                 ` Robert Dewar
1999-04-12  0:00                 ` OpenToken project announcement dennison
1999-04-11  0:00               ` Linux Kernel in Ada. Repost Robert Dewar
1999-04-10  0:00                 ` Kevin
1999-04-13  0:00                 ` Harry Tanovich
1999-04-13  0:00                   ` Robert Dewar
1999-04-11  0:00             ` Jerry van Dijk
1999-04-11  0:00           ` Jerry van Dijk
1999-04-11  0:00             ` Robert Dewar
1999-04-14  0:00               ` Aidan Skinner
1999-04-11  0:00           ` Robert Dewar
1999-04-10  0:00             ` mike
1999-04-11  0:00               ` Robert Dewar
1999-04-12  0:00                 ` Samuel Mize
1999-04-13  0:00                   ` Robert Dewar
1999-04-16  0:00                     ` Samuel Mize
1999-04-11  0:00             ` Accessing C macro constants from Ada95 Markus Kuhn
1999-04-11  0:00               ` Jerry van Dijk
1999-04-12  0:00               ` Aidan Skinner
1999-04-13  0:00                 ` Robert Dewar
1999-04-12  0:00               ` Robert Dewar
1999-04-13  0:00                 ` Markus Kuhn [this message]
1999-04-13  0:00                   ` Robert Dewar
1999-04-13  0:00                     ` dennison
1999-04-12  0:00               ` Robert Dewar
1999-04-12  0:00               ` Tarjei Tj�stheim Jensen
1999-04-12  0:00               ` Robert Dewar
1999-04-09  0:00       ` Linux Kernel in Ada. Repost Larry Kilgallen
1999-04-09  0:00         ` David Starner
1999-04-09  0:00           ` Brian Rogoff
1999-04-11  0:00           ` Robert Dewar
1999-04-12  0:00         ` Hans N. Beck
1999-04-11  0:00   ` Robert Dewar
1999-04-12  0:00     ` Bruce MacDonald
1999-05-03  0:00 ` Buz Cory
1999-05-03  0:00   ` Hans N. Beck
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox