> I suspect Ada needs something like this already. I expect the following > to work (although it is quite hideous). > > with System; > > package Import is > > function Foo return System.Address; > pragma Import (C, Foo); > > function Bar return Integer; > > end Import; > > package body Import is > > function Bar return Integer is > function Foo_2 return Integer; > pragma Import (C, Foo_2); > for Foo_2'Address use Foo'Address; > begin > return Foo_2; > end Bar; > > end Import;
System.Address is an integer though so that will always work (on 32-bit architectures) without special support. And, no, Ada doesn't need this general capabilitly, address frobbing like above is at your own risk and you certainly don't want to use access (pointer) types with it anyway. That being said, there is indeed a related issue with Ada on m68k because, when you have a C function that returns a pointer (typically malloc), you generally import it in Ada as System.Address: function malloc (Size : size_t) return System.Address; pragma Import (C, malloc, "malloc"); so the C and the Ada sides don't agree on the return register... -- Eric Botcazou