[comp.lang.c] calling ada from c

mcragg@gmu90x.UUCP (Maureen Cragg) (10/16/88)

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

mcragg@gmu90x.UUCP (Maureen Cragg) (10/18/88)

In article <1512@gmu90x.UUCP>, mcragg@gmu90x.UUCP (Maureen Cragg) writes:
> and can anyone tell me how to pass a simple integer? i'm having less luck with
> that...

i've succeeded in passing an integer: adaprint(&i) where adaprint accepts
an integer...anyone care to explain that?