From: Dmitry A. Kazakov on
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...(a)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
From: mockturtle on
On Sep 17, 6:17 pm, "Dmitry A. Kazakov" <mail...(a)dmitry-kazakov.de>
wrote:
> 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...(a)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. Kazakovhttp://www.dmitry-kazakov.de

Thank you to everyone for your help. I just discovered that it is
maybe a problem with the old GPS version: I moved the complete
"packet" to a computer with GPS 4.3.1 (20090114) and everything worked
without changing a bit. Hmmm... I am afraid that I will need to
update the older GPS.