comp.lang.ada
 help / color / mirror / Atom feed
From: Jerry van Dijk <jvandyk@attglobal.net>
Subject: Re: Interfacing a subprogram from C.
Date: 28 Feb 2002 19:15:43 +0100
Date: 2002-02-28T19:15:43+01:00	[thread overview]
Message-ID: <wkn0xt4gmo.fsf@attglobal.net> (raw)
In-Reply-To: a5lhck$6va$1@polaris.cc.upv.es

"Pedro Jose Garcia Gil" <pggil@isa.upv.es> writes:

> $gcc -c pepe.c
> What am I doing wrong?.

Your C object file is called pepe.o
 
> It's necessary to compile with other options or include some file in
> somewhere?.

More portable is:

*** c_part.c ***************************************************************
#include <stdio.h>

void c_part(int i)
{
  printf("c_part received: %d\n", i);
}
****************************************************************************

*** ada_part.adb ***********************************************************
with Interfaces.C;

procedure Ada_Part is

   procedure C_Part (I : Interfaces.C.int);
   pragma Import (C, C_Part, "c_part");
   pragma Linker_Options ("c_part.o");

begin
   C_Part (7);
end Ada_Part;
****************************************************************************

****************************************************************************
C_PART   C              87  28-02-02  19:07 c_part.c
ADA_PART ADB           213  28-02-02  19:10 ada_part.adb

C:\Home\work>gcc -c -o c_part.o c_part.c

C:\Home\work>gnatmake ada_part
gcc -c ada_part.adb
gnatbind -x ada_part.ali
gnatlink ada_part.ali

C:\Home\work>ada_part
c_part received: 7
****************************************************************************

-- 
--  Jerry van Dijk   | email: jvandyk@attglobal.net
--  Leiden, Holland  | web:   users.ncrvnet.nl/gmvdijk



  parent reply	other threads:[~2002-02-28 18:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-28 15:11 Interfacing a subprogram from C Pedro Jose Garcia Gil
2002-02-28 17:50 ` sk
2002-02-28 18:12   ` Pedro  Garcia Gil
2002-02-28 18:15 ` Jerry van Dijk [this message]
2002-02-28 23:01 ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox