comp.lang.ada
 help / color / mirror / Atom feed
* Help with ADA and C function pointers.
@ 1996-11-20  0:00 Wendell P Beckwith
  1996-11-21  0:00 ` Aaron Quantz
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Wendell P Beckwith @ 1996-11-20  0:00 UTC (permalink / raw)



I have an ada main procedure which needs to pass the address of an ada
function to a C funciton.  Using gnat 3.05 the following compiles and
generates an executable, but it cores when you run it.  I knew it would
because no where am I assigning a function to be passed.  That is what
I'd like to know how to do.  Please respond to my work email, since I'm
not in this group alot.  Thanks!!

Wendell

-- my test main
with Text_IO, Interfaces.C; 
use Text_IO;

Procedure Gmain is

	Function func(d : in Integer) return Integer is
	Begin
		return (2 * d);
	End;
	type func_type is access Function(d : in Integer) return Integer;
	funcptr : func_type;
	
	Procedure Stuff(f : in func_type);
	pragma Import(C, Stuff, "stuff");
	
Begin
	Stuff(funcptr);
End;

-- my test C function using the ada callback
#include <stdio.h>

void stuff(int (*function)(int))
{
	printf("Value = %d\n", (*function)(10));
}




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

end of thread, other threads:[~1996-11-26  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-11-20  0:00 Help with ADA and C function pointers Wendell P Beckwith
1996-11-21  0:00 ` Aaron Quantz
1996-11-22  0:00   ` THANKS! (was Help with ADA and C function pointers.) Wendell P Beckwith
1996-11-22  0:00 ` Help with ADA and C function pointers Stephen Leake
1996-11-26  0:00 ` fd
1996-11-26  0:00 ` fd

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