comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada file depends on C file
Date: Thu, 17 Sep 2009 18:17:47 +0200
Date: 2009-09-17T18:17:43+02:00	[thread overview]
Message-ID: <1ti6i9vyr5k4x$.ynnox0weminr$.dlg@40tude.net> (raw)
In-Reply-To: 64e357f1-367d-4791-9307-49e8cc678c18@p36g2000vbn.googlegroups.com

On Thu, 17 Sep 2009 07:49:46 -0700 (PDT), Ludovic Brenta wrote:

> mockturtle wrote on comp.lang.ada:
>> On Sep 17, 3:07�pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
>>> I normally use a Makefile to compile in such situations but there are
>>> two alternatives: gprmake and its successor, gprbuild. In GPS, you can
>>> specify that your project is multi-language; this will cause it to
>>> call the proper tool (instead of gnatmake, which is for Ada-only
>>
>> I did. �If I open with an editor the .gpr file created by GPS I find
>> the line
>>
>> � �for Languages use ("Ada", "C");
> 
> From memory, this is necessary but not sufficient; you also have to
> tick a check box somewhere to tell GPS that your project file is multi-
> language. This is confusing, I know, and I learned the hard way :)

Hmm, adding C files into the list of sources should suffice. For example,
the following works for me:

------- mixed.gpr
project Mixed is
   for Languages use ("Ada", "C");
   for Source_Dirs use (".");
   for Source_Files use ("main.adb", "c.c");
   for Main use ("main.adb");
end Mixed;
------ main.adb
with Ada.Text_IO;   use Ada.Text_IO;
with Interfaces.C;  use Interfaces.C;

procedure Main is
   function C return Int;
   pragma Import (C, C);
begin
   Put_Line ("Value:" & Int'Image (C));
end Main;
------ c.c
int c (void)
{
   return 123;
}
----------------------------------------------
This should compile under GPS and print

Value: 123

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2009-09-17 16:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-17 12:38 Ada file depends on C file mockturtle
2009-09-17 13:07 ` Ludovic Brenta
2009-09-17 13:32   ` mockturtle
2009-09-17 14:49     ` Ludovic Brenta
2009-09-17 16:17       ` Dmitry A. Kazakov [this message]
2009-09-17 17:35         ` mockturtle
2009-09-17 13:29 ` Dmitry A. Kazakov
replies disabled

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