comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-dejanews.com>
Subject: Re: Accessing C macro constants from Ada95
Date: 1999/04/12
Date: 1999-04-12T00:00:00+00:00	[thread overview]
Message-ID: <7erp6b$o3f$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 7eqoj2$r27$1@pegasus.csx.cam.ac.uk

In article <7eqoj2$r27$1@pegasus.csx.cam.ac.uk>,
  mgk25@cl.cam.ac.uk (Markus Kuhn) wrote:
> Ada does indeed have nice facilities to access functions
> and variables in C object files, but what has been
> completely forgotten is that
> under C, traditionally a very significant part of the API
> comes in the form of numeric macro constants defined in
> *.h files.

This was most certainly not "forgotten" ...

> What would be necessary is that every
> Ada95 compiler that implements a C interface contains a
complete
> ISO C macro preprocessor. An import pragma would then
allow to extract
> an arbitrary numeric constant from any specifyable *.h
file and
> could then be used as an Ada constant.

This is so impractical that I can't tell if you are really
serious. In
any case you do a good job of indicating why there is no
automatic
feature for importing such constants!

> And Ada95 does not provide a portable way to get at
> these.

You mean apart from defining them, copying the constants
(no different in principle from copying the parameters
when you pragma Import something ....)

> Ada programmers should not have to write buggy and
> dangerous Perl hacks again and again to get access to the
> constants in C header files.

I don't think they should do this even once, I certainly
never have, and have accessed such constants many times.

Basically, when importing functions or constants, we have
two ways
of doing things.

We either look at the header, and manually acquire the
functions and
their parameters, and any constant values needed, and write
the
necessary declarations in our Ada program manually.

Or we use a program like c2ada, or the SGI binding
generator that reads
a header and automaticlly extracts this information.

I do not see the big deal here!

If you have a situation where the constants can change and
you do not
want to have to modify the Ada accordingly, then it is easy
enough (again
manually or automatically) to write simple C functions that
"cloak" the
constants.

I must say I have never found this to be a significant
difficulty.

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!


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  parent reply	other threads:[~1999-04-12  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     ` 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               ` Tarjei Tj�stheim Jensen
1999-04-12  0:00               ` Robert Dewar
1999-04-12  0:00               ` Robert Dewar [this message]
1999-04-13  0:00                 ` Markus Kuhn
1999-04-13  0:00                   ` Robert Dewar
1999-04-13  0:00                     ` dennison
1999-04-12  0:00               ` Aidan Skinner
1999-04-13  0:00                 ` Robert Dewar
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-09  0:00     ` Jeffrey D. Cherry
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