comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Interfacing to C and types visible to Ada
Date: Thu, 3 Jul 2008 05:32:26 -0700 (PDT)
Date: 2008-07-03T05:32:26-07:00	[thread overview]
Message-ID: <ff92d09d-5638-4422-ab11-d214529c0283@l64g2000hse.googlegroups.com> (raw)

I have a question related to interfacing to C, but I think it deserves
a new thread.

Imagine a C API that uses the int type to express something that does
not have any dedicated domain. In other words, it is not "number of
apples", not "height in meters", not "hotel room number", etc., it is
just plain "integer", which meaning can depend on how the given
library is actually used.

We can use Interfaces.C.int for binding Ada to C, but there is still a
need to expose somehow the type to regular Ada code. What type should
be used?

Standard.Integer is the most natural choice, because it clearly
expresses the "domainless" character of the given type. On the other
hand, it might not be the same as Interfaces.C.int in terms of its
range.

Interfaces.C.int might be a good choice as well, because it
"guarantees" (modulo what we have discussed in another thread) that
the information is transported correctly. The disadvantage is that it
is ugly and exposes implementation details which are not needed.

The Ada wrapper library might also define its own type that will be
equivalent in range to Interfaces.C.int. What is the right name for
such a type? "Integer" is the best choice due to the character of this
type, but it collides with Standard.Integer. On the other hand,
packages are supposed to be the cure for such conflicts.

What do you recommend? I would go for the last option: "Integer"
defined in the library's package.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



             reply	other threads:[~2008-07-03 12:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-03 12:32 Maciej Sobczak [this message]
2008-07-03 12:52 ` Interfacing to C and types visible to Ada Georg Bauhaus
2008-07-03 12:58 ` Ludovic Brenta
2008-07-03 14:33 ` Robert A Duff
2008-07-03 19:19 ` tmoran
2008-07-03 19:35 ` Keith Thompson
2008-07-03 20:35   ` Maciej Sobczak
2008-07-05 20:08     ` Fionn Mac Cumhaill
2008-07-04  4:36 ` Steve
replies disabled

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