calling ada from c
Maureen Cragg
mcragg at gmu90x.UUCP
Sun Oct 16 10:23:42 AEST 1988
i have successfully called c functions from ada (the pragma import works fine),
but i'm having more difficulty the other way...
i'm trying to pass a string from c to ada:
extern void adaprint_s(char *str);
char str[81];
main(){
puts("enter a string:");
gets(str);
adaprint_s(str);
}
package adaprint is
type string_ptr is access string(1..81);
procedure adaprint_s(
str : IN string_ptr );
pragma export_procedure(internal=>adaprint_s,external=>adaprint_s,
parameter_types=>(string_ptr));
end;
with text_io;
use text_io;
package body adaprint is
procedure adaprint_s(
str : IN string_ptr )
is
begin
put("the string is:");
put_line(str.all);
end;
end;
now it looks like i'm passing the address of a string to ada, which is expect-
ing a string pointer, but somehow my adaprint.str is set to the first 4 char-
acters of the string, in reverse order! (i've inspected the values with debug).
if i pass the address of the string pointer ( adaprint_s(&str); ) everything
works fine, but i'm at a loss to understand this behavior...
if anyone out there can explain this to me, i'll sleep better tonight;-)
and can anyone tell me how to pass a simple integer? i'm having less luck with
that...
adTHANXvance,
the air drummer
More information about the Comp.lang.c
mailing list