comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: Ada array vs C pointer (call by reference)
Date: Sun, 29 Jun 2008 03:48:52 GMT
Date: 2008-06-29T03:48:52+00:00	[thread overview]
Message-ID: <ECD9k.80923$102.52985@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: 5d649522-50be-4aa5-9dce-cd1daa2bcd0d@p39g2000prm.googlegroups.com

All credited languages and their compilers use "Standards" for their Data 
representation, such as IEEE.  Which means that as along as you use the 
compilers that share the same standard or you code an understand of 
these differences in those standards in your routine you can be safe that 
your code will perform correctly.


In <5d649522-50be-4aa5-9dce-cd1daa2bcd0d@p39g2000prm.googlegroups.com>, Adrian Hoe <abyhoe@gmail.com> writes:
>On Jun 28, 6:54 am, "Jeffrey R. Carter"
><spam.jrcarter....@spam.acm.org> wrote:
>> Adrian Hoe wrote:
>>
>> > Can I use Float instead of Interfaces.C.C_Float?
>>
>> You can use anything you want: Boolean, Duration, a task type, ...
>>
>> But if you want to be sure it will work, you'll use Interfaces.C.C_Float.
>>
>> > Why use Interfaces.C.Int, Interfaces.C.C_Float since they are all new
>> > declaration of Ada types.
>>
>> > I know it is for readability and maintainability but the question is
>> > logical as the declaration in Interfaces.C is just merely creating a
>> > new Ada type with a new name, unless there is pragma Convention
>> > statement after every such declaration in Interfaces.C.
>>
>> I suggest you read ARM B.3. There you'll find, "Each of the types declared in
>> Interfaces.C is C-compatible."
>>
>> > Wouldn't it be better to write as such?
>>
>> > type C_Data is array (Positive range <>) of Float;
>> > pragma Convention (C, C_Data);
>>
>> Not if you want to be sure it will work.
>>
>> > Is PWM_Data passed as pointer to pwmRead?
>>
>> B.3 also contains, "An Ada parameter of an array type with component type T, of
>> any mode, is passed as a t* argument to a C function, where t is the C type
>> corresponding to the Ada type T."
>
>
>Ok. Ada somewhat guarantees a safe environment of its own. The
>ultimate concern is how Ada (or we) can guarantee a safe interfacing
>to C?
>
>Like those previous posts in this thread (by Maciej, Keith, et al), it
>depends on compiler implementation. The question is, the C library
>(which I am interfacing with) is compiled by unknown C compiler with
>unknown switches and the author cannot be contacted. The only
>documentation I have is the C header file. Can Ada safe implementation
>guarantee a safe interface in this case? Or rather, how Ada can
>guarantee a safe interface?
>
>This does not limit to float * but can be anything else. The reason I/
>we ask this (stupid) question is that I want to eliminate undesired
>results because the results returned will be difficult to trace/prove
>for correctness.
>--
>Adrian Hoe
>http://adrianhoe.com




  parent reply	other threads:[~2008-06-29  3:48 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-27  1:39 Ada array vs C pointer (call by reference) Adrian Hoe
2008-06-27  1:42 ` Adrian Hoe
2008-06-27  2:55 ` Adam Beneschan
2008-06-27 13:02   ` Maciej Sobczak
2008-06-27 13:15     ` Adrian Hoe
2008-06-27 14:43     ` Georg Bauhaus
2008-06-27 14:47       ` Georg Bauhaus
2008-06-27 20:35       ` Maciej Sobczak
2008-06-27 22:00         ` Georg Bauhaus
2008-06-27 22:46           ` Keith Thompson
2008-06-27 16:11     ` Keith Thompson
2008-06-27 17:00       ` Robert A Duff
2008-06-27 18:15         ` Keith Thompson
2008-06-28 14:02         ` Stephen Leake
2008-06-28 21:18           ` Keith Thompson
2008-07-03 12:44         ` Rob Norris
2008-06-27 20:44       ` Maciej Sobczak
2008-06-27 22:14         ` Keith Thompson
2008-06-27 22:36           ` Adam Beneschan
2008-06-28 14:04             ` Stephen Leake
2008-06-28 21:22               ` Keith Thompson
2008-06-30 17:13               ` Adam Beneschan
2008-06-28 17:52             ` Robert A Duff
2008-06-30 17:13               ` Adam Beneschan
2008-06-30 18:55                 ` Robert A Duff
2008-07-01 21:19                 ` Randy Brukardt
2008-07-01 21:19                 ` Randy Brukardt
2008-06-28  0:56         ` Peter C. Chapin
2008-06-28 14:11           ` Maciej Sobczak
2008-06-28 17:49             ` tmoran
2008-06-28 21:46             ` Keith Thompson
2008-06-28 17:44         ` Robert A Duff
2008-07-01 21:10       ` Randy Brukardt
2008-06-27 18:13     ` tmoran
2008-06-27 20:49       ` Maciej Sobczak
2008-06-27  4:10 ` Jeffrey R. Carter
2008-06-27  8:22   ` Adrian Hoe
2008-06-27 15:07     ` Adam Beneschan
2008-06-27 22:54     ` Jeffrey R. Carter
2008-06-28  1:15       ` Adrian Hoe
2008-06-28  2:17         ` Adam Beneschan
2008-07-01 21:31           ` Randy Brukardt
2008-07-01 21:31           ` Randy Brukardt
2008-08-22  4:06           ` Adrian Hoe
2008-06-28  4:59         ` Jeffrey R. Carter
2008-06-29  3:48         ` anon [this message]
2008-06-28  1:21 ` anon
replies disabled

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