From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3b06f2a3754e334e,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.glorb.com!logbridge.uoregon.edu!tethys.csu.net!nntp.csufresno.edu!sn-xt-sjc-02!sn-xt-sjc-01!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail From: "Xcriber51" Newsgroups: comp.lang.ada Subject: GPS example fails to compile Date: Wed, 21 Jun 2006 16:43:00 -0400 Organization: www.talkaboutprogramming.com Message-ID: X-Newsreader: www.talkaboutprogramming.com X-Problems-To: info at talkaboutnetwork.com X-Posted-By: USERID-24116 Content-Type: text/plain; X-Complaints-To: abuse@supernews.com Xref: g2news2.google.com comp.lang.ada:4882 Date: 2006-06-21T16:43:00-04:00 List-Id: 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?