comp.lang.ada
 help / color / mirror / Atom feed
From: "Xcriber51" <xcriber@[OMITTED]>
Subject: GPS example fails to compile
Date: Wed, 21 Jun 2006 16:43:00 -0400
Date: 2006-06-21T16:43:00-04:00	[thread overview]
Message-ID: <ab29599196bb2f30761a00d3366d9425@localhost.talkaboutprogramming.com> (raw)

Hi

After finally deciding to dive into the world of a language that requires
you to write...

    function Get_It (n: Integer) return Integer;

..what you can say in C as...

    int get_it (int n);
    
..I have downloaded the much-touted GPS IDE. 

Have I pissed you off already? Ok, that was just to get your attention,
forget that.

Seriously, after installing the IDE, I went ahead with the first tutorial:
SDC (the simple calculator), under "C:\GPS\doc\gps\examples\demo" (with the
default Windows installation), defined by the project file "sdc.gpr".

When I reached the full compilation stage of the Tutorial, I got a nasty
failure: gnatmake stops at "matrix_binding.adb", telling me that a series
of binding functions have "undefined reference to" 'name-of-function'.

The functions are in a C file ("matrix_utils.c" and/or "matrix.h")
included in the project. 

But my question is this: As I was trying to figure out how Ada manages
binding with external language modules (in our case with C code), I saw
that it uses the following syntax:

    function Alloc (Rows, Columns : Integer) return Matrix_Type is
        function C_Alloc (Rows, Columns : short) return Matrix_Type;
        pragma Import (C, C_Alloc, "matrixAlloc");
    begin
        return C_Alloc (short (Rows), short (Columns));
    end Alloc;

Now as I gather from another example in this forum, this "Import" function
works like so:

    -- Based on our example
    pragma Import (
        Convention      => C,
        Entity          => C_Alloc,
        External_Name   => "matrixAlloc"
        );

That's fine, but how does the compiler know where the heck "matrixAlloc"
is? I can't see the actual C file where the "matrixAlloc" and similar
functions are located included or explicitly referred to in the
"matrix_binding.ads" file, either. 

I checked:

- the .GPR file - the project directories are listed there, but not the
actual external module names;

- the GPS help system (which has topic headings like
"Interfaces.C.Strings", although they don't lead to any help files - that
link refers to an .ADS file, for instance);

- "Ada Distilled", the Wikibook "Ada Programming", the site "AdaPower",
etc.

I just couldn't find something that actually explains this to me.

Obviously - by Eric Raymondian criteria -, I'm dumb.

Any patient soul out there to explain how the f--- Ada does binding with
an external language module? (Not the "pragma import" construct, dammit,
but how the whole thing comes together.)

Thanks, patient soul!


-- Ken

P.S. Oh, and by the way: Why doesn't the example compile? Is it because I
installed GPS on an XP system when it was a full moon?






             reply	other threads:[~2006-06-21 20:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-21 20:43 Xcriber51 [this message]
2006-06-21 20:56 ` GPS example fails to compile Pascal Obry
2006-06-21 21:16   ` Xcriber51
2006-06-21 21:12 ` Gautier
2006-06-22  5:00 ` Jeffrey R. Carter
2006-06-22 11:29 ` Stephen Leake
2006-06-22 22:41 ` Simon Wright
2006-06-23  8:18   ` Ludovic Brenta
2006-06-23 12:59     ` Alex R. Mosteo
2006-06-23 19:35       ` Xcriber51
2006-06-25 20:41       ` Simon Wright
2006-06-26  6:58         ` Alex R. Mosteo
replies disabled

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