comp.lang.ada
 help / color / mirror / Atom feed
* Size of a pointer to a tagged record
@ 2002-12-04 14:01 Steven Murdoch
  2002-12-04 15:16 ` Robert A Duff
  2002-12-04 17:05 ` Jeffrey Carter
  0 siblings, 2 replies; 10+ messages in thread
From: Steven Murdoch @ 2002-12-04 14:01 UTC (permalink / raw)


I am writing a binding to the Lua (http://www.lua.org/)
scripting language (which is written in C). One thing I
need to do is store a pointer to a tagged record in a
memory location allocated by malloc. For this reason I need
to know the size.

If a pointer to a tagged record is equivalent to a
System.Address then I can store this in a memory location
of sizeof(void *), however if the tag is stored in the
pointer rather than the record then I would need to
allocate space for the tag as well.

If a pointer to a tagged record is equivalent to a
System.Address then I would use the following code:

--

type Parameter is tagged private;
type Parameter_Access is access all Parameter'Class;

package Convert is new
     System.Address_To_Access_Conversions(Parameter);

addr: System.Address;
param: Parameter_Access;

addr:=Get_Void_Pointer; --Void* from C
param:=Parameter_Access(User_Data_Convert.To_Pointer(Address));

--

At the end of this code I would use param as a normal pointer
to a tagged record. Does this look OK? Is there a better way
to achieve the same thing.

I am using GNAT 3.13p but I would like the code to be as
cross platform/compiler as possible.

Thanks in advance,
Steven Murdoch.



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-12-07  6:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-04 14:01 Size of a pointer to a tagged record Steven Murdoch
2002-12-04 15:16 ` Robert A Duff
2002-12-04 15:44   ` Steven Murdoch
2002-12-04 17:17     ` Robert A Duff
2002-12-04 17:56       ` Steven Murdoch
2002-12-04 19:10         ` Robert A Duff
2002-12-07  6:55         ` David Thompson
2002-12-04 20:27       ` Simon Wright
2002-12-04 18:11     ` tmoran
2002-12-04 17:05 ` Jeffrey Carter

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