C and ADA

B

Brian

Hi I have an ADA function that I'd like to call from my C program.

Is there any way to provide a .h file containing a C prototype for the
ADA function and then link the ADA with the C? Does anyone have any
experience of this?

I'm using a GNU setup on Linux.

Thanks.
 
H

Harald van Dijk

Hi I have an ADA function that I'd like to call from my C program.

Is there any way to provide a .h file containing a C prototype for the
ADA function and then link the ADA with the C? Does anyone have any
experience of this?

C doesn't define how to mix C with other languages. I believe Ada does
define how to mix Ada with other languages, so you're better off asking
in an Ada newsgroup.
 
K

Keith Thompson

Brian said:
Hi I have an ADA function that I'd like to call from my C program.

Is there any way to provide a .h file containing a C prototype for the
ADA function and then link the ADA with the C? Does anyone have any
experience of this?

I'm using a GNU setup on Linux.

Ada (not "ADA"; it's not an acronym) provides mechanisms for
cross-language calls between Ada and C; C does not. The folks in
comp.lang.c won't be able to answer your question. I've redirected
followups just to comp.lang.ada, and I suggest that others do
likewise.
 
L

Lucretia

Hi I have an ADA function that I'd like to call from my C program.

Is there any way to provide a .h file containing a C prototype for the
ADA function and then link the ADA with the C? Does anyone have any
experience of this?

I'm using a GNU setup on Linux.

Thanks.

You can add a "pragma Export" to your procedure and compile it with
gnat. There is a chapter on mixed language programming in the GNAT
manual. But I think you might end up having to build the app with
gnat. Surely porting the procedure would be easier?

Luke.
 
J

Jerry

Hi I have an ADA function that I'd like to call from my C program.

Is there any way to provide a .h file containing a C prototype for the
ADA function and then link the ADA with the C? Does anyone have any
experience of this?

I'm using a GNU setup on Linux.

Thanks.

This process is described here (as well as the opposite process where
the main program is Ada);

http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Interfacing-to-C.html#Interfacing-to-C


Also, see the Ada Reference Manual:

http://www.adaic.com/standards/05rm/html/RM-B-3.html


FWIW, I've done this sort of thing using GPC, the GNU Pascal compiler,
with good results.

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top