comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca>
Subject: Re: Importing C structs?
Date: Thu, 31 Jul 2003 13:32:22 -0400
Date: 2003-07-31T13:32:22-04:00	[thread overview]
Message-ID: <BocWa.1390$qN3.188377@news20.bellglobal.com> (raw)
In-Reply-To: <1ec946d1.0307310859.67460c46@posting.google.com>

Matthew Heaney wrote:
> Ching Bon Lam <c.lam_REMOVE_THIS@student.utwente.nl> wrote in message news:<Xns93C98A38494B8cblamstudentutwenten@194.109.133.20>...
> 
>>"Matthew Heaney" <matthewjheaney@earthlink.net> wrote in
>>news:1V1Wa.299$jp.55@newsread4.news.pas.earthlink.net: 
>>
>>>This is probably overkill.  For an opaque type all you need to do is:
>>>
>>>type DB_Type is limited null record;
>>>type DB_Access is access all DB_Type;
>>>for DB_Access'Storage_Size use 0;
>>>pragma Convention (C, DB_Access);
>>
>>overkill? i don't think so.. opaque_structure_def is defined in 
>>Interfaces.C.Extensions (i-cexten.ads in gnat) as:
>>
>>subtype opaque_structure_def is System.Address;
>>
>>just a memory address. That's the same as DB *. Since the api (well, most 
>>api written in C) only use DB * and not DB, you don't need another access 
>>type. that's why 
> 
> A memory address is not the same thing as DB*.  A "memory address" has
> type void*.  A void* can point to anything.  A DB* can not.
> 
> You are free of course to use System.Address everywhere in Ada, just
> as you are free to use void* everywhere in C, but you lose strong
> typing that way.  There is a reason why the C API used type DB* and
> not type void*.
> 
> So I stand by my assertion that type opaque_structure_def is not the
> correct choice for a binding to dbopen().

 From what I have seen in this thread, this "project"
should be a "binding" so that these types of entities are
not directly used by a client program.

In this way, you can carry DB* arround any way that makes
sense, as long as it is properly preserved internally
(perhaps in an Ada tagged record), and nulled
when it is invalid to reference it.

Sometimes within a binding, an external entity's precise makeup
cannot be [conveniently/portably] known. But if you only need
to reference it, then this is no hardship. You then only have
to properly manage its use.

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




  reply	other threads:[~2003-07-31 17:32 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-30 20:03 Importing C structs? Freejack
2003-07-30 20:52 ` chris
2003-07-30 21:26   ` Freejack
2003-07-30 23:50   ` tmoran
2003-07-31 10:53     ` chris
2003-08-04 14:33     ` Andreas Almroth
2003-08-04 15:16       ` Samuel Tardieu
2003-08-04 20:07         ` Randy Brukardt
2003-07-31 17:14   ` Warren W. Gay VE3WWG
2003-08-12  0:02     ` chris
2003-07-31 18:17   ` Xenos
2003-07-31 19:16     ` Simon Wright
2003-07-31 20:17       ` Samuel Tardieu
2003-07-31 20:40       ` Xenos
2003-07-30 23:14 ` Ching Bon Lam
2003-07-31  0:07   ` tmoran
2003-07-31  5:35   ` Matthew Heaney
2003-07-31  7:46     ` Freejack
2003-07-31  9:27       ` Martin Dowie
2003-07-31 21:41         ` Freejack
2003-08-01  7:39           ` Martin Dowie
2003-07-31 17:34       ` Matthew Heaney
2003-07-31 11:29     ` Ching Bon Lam
2003-07-31 16:59       ` Matthew Heaney
2003-07-31 17:32         ` Warren W. Gay VE3WWG [this message]
2003-07-31 17:13       ` Matthew Heaney
2003-07-31 17:40       ` Randy Brukardt
2003-07-31  5:21 ` Matthew Heaney
replies disabled

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