C and ADA

Discussion in 'C Programming' started by Brian, Jan 2, 2008.

  1. Brian

    Brian Guest

    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.
     
    Brian, Jan 2, 2008
    #1
    1. Advertising

  2. On Wed, 02 Jan 2008 23:33:10 +0100, Brian wrote:
    > 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.
     
    Harald van Dijk, Jan 2, 2008
    #2
    1. Advertising

  3. Brian <> writes:
    > 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.

    --
    Keith Thompson (The_Other_Keith) <>
    [...]
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Jan 2, 2008
    #3
  4. Brian

    Lucretia Guest

    On Jan 2, 10:33 pm, Brian <> wrote:
    > 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.
     
    Lucretia, Jan 2, 2008
    #4
  5. Brian

    Jerry Guest

    On Jan 2, 3:33 pm, Brian <> wrote:
    > 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
     
    Jerry, Jan 3, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joona I Palaste

    Re: Ada performance (was No call for Ada )

    Joona I Palaste, Feb 15, 2004, in forum: Java
    Replies:
    0
    Views:
    466
    Joona I Palaste
    Feb 15, 2004
  2. Replies:
    5
    Views:
    633
    TechBookReport
    Mar 23, 2006
  3. Ken

    ADA/C++/IDL to XML?

    Ken, Sep 5, 2003, in forum: XML
    Replies:
    0
    Views:
    667
  4. Marc A. Criley
    Replies:
    0
    Views:
    384
    Marc A. Criley
    Mar 11, 2005
  5. Robert Dober
    Replies:
    4
    Views:
    206
    Robert Dober
    Apr 22, 2008
Loading...

Share This Page