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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a4ce2c0817cfc70b X-Google-Attributes: gid103376,public From: "Theodore E. Dennison" Subject: Re: C to Ada interfacing Date: 1996/08/01 Message-ID: <3200AD3E.41C67EA6@escmail.orl.mmc.com>#1/1 X-Deja-AN: 171411906 references: <4tm4mg$cjp@optional.cts.com> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Information Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.0 (X11; I; SunOS 4.1.3_U1 sun4m) Date: 1996-08-01T00:00:00+00:00 List-Id: Lee Slaughter wrote: > > I'm not an Ada programmer but need to interface with Ada > routines from C (on a VxWorks platform). > > In my probably naive view i'd make a call to someAdaFn( arg ) > and my Ada-programmer peer would define this function in some > .ada or whatever source file who's > object file would be linked in with the C .o stuff, and of > course have to take special care to be sure data types align, > are in the right order with right number of gaps and all. > > Is that sort of sketchily it? It depends on what the someAdaFn does. If it "withs" in other Ada packages, It probably requires elaboration by the Ada runtime. In this case, you'll probably have to either - o write the program's "main" in Ada. It can then call your C code which will eventually call someAdaFn. (Ada has better support for running C than C does for running Ada). o make a call to the Ada runtime's elaboration routine before you call someAdaFn. Other points: Since the Ada runtime won't be there (unless you choose the first option above), someAdaFn can't create or rendezvous with any tasks, and may not even be able to perform a "delay", or do dynamic allocation. You also have to be careful about passing dynamicly-allocated data between Ada and C. I have seen situations where this caused problems that could only be solved by redefining "malloc" to call an Ada routine to do the dynamic allocation. -- T.E.D. | Work - mailto:dennison@escmail.orl.mmc.com | | Home - mailto:dennison@iag.net | | URL - http://www.iag.net/~dennison |