comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: What is the best way to define the Imported C function
Date: Mon, 28 Jan 2008 09:18:17 -0800 (PST)
Date: 2008-01-28T09:18:17-08:00	[thread overview]
Message-ID: <63f505fe-19fc-48e1-8c7c-f4bcb52c99df@m34g2000hsf.googlegroups.com> (raw)
In-Reply-To: 6aRmj.3192$yE1.490@attbi_s21

On Jan 26, 5:31 pm, "Jeffrey R. Carter"
<spam.jrcarter....@acm.nospam.org> wrote:

> I can't help you (and really, neither can those who have replied to you) because
> the C specification isn't a specification; it doesn't tell us how the function
> uses its parameters. Without that information, we can't tell how to interface to it.
>
> The problem is that C uses the same construct for many conceptually different
> things. For example:
>
> void f (char* c);
>
> may represent something that is conceptually equivalent to Ada's
>
> procedure F (C : in Character); [unlikely, but possible]
> procedure F (C : in out Character);
> procedure F (C : out Character);
> procedure F (C : in String);
> procedure F (C : in out String);
> procedure F (C : out String);
>
> Given the common practice of using "char" to represent what Ada calls a
> Storage_Element, and "char[]" or "char*" for Storage_Array, this single C
> declaration may mean any of 12 different things.

It's probably worse than that, because even when char * refers to a
structure with multiple characters rather than a single character, you
don't know whether it's supposed to be a null-terminated string, or an
array of characters whose size is given somewhere else, or what.

                               -- Adam





      reply	other threads:[~2008-01-28 17:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-26  5:05 What is the best way to define the Imported C function qunying
2008-01-26 10:15 ` Martin Krischik
2008-01-26 16:24   ` qunying
2008-01-26 10:56 ` Dmitry A. Kazakov
2008-01-26 12:15   ` Stefan Lucks
2008-01-27  1:31 ` Jeffrey R. Carter
2008-01-28 17:18   ` Adam Beneschan [this message]
replies disabled

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