From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_05,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Xref: utzoo comp.lang.ada:1517 comp.lang.c:13287 Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!pyrnj!pyrdc!gmu90x!mcragg From: mcragg@gmu90x.UUCP (Maureen Cragg) Newsgroups: comp.lang.ada,comp.lang.c Subject: calling ada from c Keywords: DECAda Message-ID: <1512@gmu90x.UUCP> Date: 16 Oct 88 00:23:42 GMT Organization: George Mason University, Fairfax, Va. List-Id: 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