comp.lang.ada
 help / color / mirror / Atom feed
* External C functions and ADA
@ 1996-08-24  0:00 Joseph Fabian
  1996-08-26  0:00 ` Jim Dorman
  0 siblings, 1 reply; 4+ messages in thread
From: Joseph Fabian @ 1996-08-24  0:00 UTC (permalink / raw)



Hi.   For the last week I've been trying desperately to figure out how to 
call a simple user defined C function from within an ADA program, without 
the slightest bit of success I might add.  I'm using the Meridian compiler, 
which is an older ADA83 compliant program, because that happens to be the 
compiler of choice at the school I'll be attending next semester.  In a 
package spec, I'm declaring the subprogram like this:
 
  Procedure Clrscrn;
  Pragma Interface(C, Clrscrn);

This compiles beautifully.  Then I wrote the corresponding C function, 
compiled it and moved the object file to the ADA directory.  I then wrote a 
simple driver program to call the imported C function, which compiled fine 
also.  All that's left is to link it all together right ?  Well, that's 
where the bombs start dropping.  The link error "Unresolved Externals: 
_Clrscrn", has spent more time on my monitor than any code I've been 
writing lately.  All I can think is that the linker isn't finding the 
object code for the interface function.  Either I'm not putting it in the 
right directory, or I'm not naming the file correctly, or something.  This 
shouldn't be that difficult.  If anyone with experience in this area, or 
with the Meridian compiler itself, has any suggestions they'd be greatly 
appreciated.  I mean GREATLY appreciated !!          





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: External C functions and ADA
  1996-08-24  0:00 External C functions and ADA Joseph Fabian
@ 1996-08-26  0:00 ` Jim Dorman
  0 siblings, 0 replies; 4+ messages in thread
From: Jim Dorman @ 1996-08-26  0:00 UTC (permalink / raw)



If you are trying to use C with Ada you might want to quit using your
Meridian compiler and invest in one from a company that still supports
them.  You can do that inexpensively with an Ada83 version of IntegrAda
that contains some Ada95 features like IMPORT/EXPORT and also has an
interface to both Microsoft & Borland C.

You can choose either a DOS or Windows environment and many ready-made
AdaUser libraries to help you.  You can also add in AdaGraphics or AdaData
if you are trying to use C to build a something graphical or link up with
dBASE or Clipper databases.

Stop by our WEB Site at "http://www.pcada.com" and take a look at what your
choices are.  I'll even take your Meridian compiler in on trade.

I look forward to hearing from you!

-- 
Jim Dorman
Active Engineering Technologies, Inc.
Home of PC ADA
Voice:  (619) 414-9001
Fax:     (619) 414-9192
email:  jimd@pcada.com
URL:  http://www.pcada.com
Member of Team Ada!

Joseph Fabian <CrsadrJoe@gnn.com> wrote in article
<4vocdh$c0j@news-e2c.gnn.com>...
> Hi.   For the last week I've been trying desperately to figure out how to

> call a simple user defined C function from within an ADA program, without

> the slightest bit of success I might add.  I'm using the Meridian
compiler, 
> which is an older ADA83 compliant program, because that happens to be the

> compiler of choice at the school I'll be attending next semester.  In a 
> package spec, I'm declaring the subprogram like this:
>  
>   Procedure Clrscrn;
>   Pragma Interface(C, Clrscrn);
> 
> This compiles beautifully.  Then I wrote the corresponding C function, 
> compiled it and moved the object file to the ADA directory.  I then wrote
a 
> simple driver program to call the imported C function, which compiled
fine 
> also.  All that's left is to link it all together right ?  Well, that's 
> where the bombs start dropping.  The link error "Unresolved Externals: 
> _Clrscrn", has spent more time on my monitor than any code I've been 
> writing lately.  All I can think is that the linker isn't finding the 
> object code for the interface function.  Either I'm not putting it in the

> right directory, or I'm not naming the file correctly, or something. 
This 
> shouldn't be that difficult.  If anyone with experience in this area, or 
> with the Meridian compiler itself, has any suggestions they'd be greatly 
> appreciated.  I mean GREATLY appreciated !!          
> 
> 




^ permalink raw reply	[flat|nested] 4+ messages in thread

* External C functions and Ada
@ 1996-08-27  0:00 Mark Bell
  1996-08-28  0:00 ` Arthur Evans Jr
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Bell @ 1996-08-27  0:00 UTC (permalink / raw)



24-Aug-96 19:03	CrsadrJoe@gnn.com (Joseph Fabian) writes :

>Hi.   For the last week I've been trying desperately to figure out how to 
>call a simple user defined C function from within an ADA program, without 
>the slightest bit of success I might add.  I'm using the Meridian compiler, 
>which is an older ADA83 compliant program, because that happens to be the 
>compiler of choice at the school I'll be attending next semester.  In a 
>package spec, I'm declaring the subprogram like this:

Joe --

Try the following :
 
  Procedure Clrscrn;
  Pragma Interface(C, Clrscrn);
  Pragma Interface_Name(Clrscn,"_Clrscrn");

The last argument of Interface_Name is a string which denotes the name
of the external subprogram as defined in the other language (in
this case C).  The first argument is the name by which the subprogram 
is known to Ada.  I'll assumme that Meridian Ada supports this...

Regards


Mark S. Bell                           412-268-7925 (Voice)
Software Engineering Institute         412-268-5758 (Fax)
Carnegie Mellon University             ** These are my opinions, 
4500 Fifth Ave, Pittsburgh PA.,15213      not those of the SEI or CMU **




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: External C functions and Ada
  1996-08-27  0:00 External C functions and Ada Mark Bell
@ 1996-08-28  0:00 ` Arthur Evans Jr
  0 siblings, 0 replies; 4+ messages in thread
From: Arthur Evans Jr @ 1996-08-28  0:00 UTC (permalink / raw)



In article <4vv2u4$fp8@news.sei.cmu.edu>, msb@sei.cmu.edu (Mark Bell) wrote:

> 24-Aug-96 19:03   CrsadrJoe@gnn.com (Joseph Fabian) writes :
> 
> >Hi.   For the last week I've been trying desperately to figure out how to 
> >call a simple user defined C function from within an ADA program, without 
> >the slightest bit of success I might add.  I'm using the Meridian compiler, 
> >which is an older ADA83 compliant program, because that happens to be the 
> >compiler of choice at the school I'll be attending next semester.  In a 
> >package spec, I'm declaring the subprogram like this:
> 
> Joe --
> 
> Try the following :
>  
>   Procedure Clrscrn;
>   Pragma Interface(C, Clrscrn);
>   Pragma Interface_Name(Clrscn,"_Clrscrn");
> 
> The last argument of Interface_Name is a string which denotes the name
> of the external subprogram as defined in the other language (in
> this case C).  The first argument is the name by which the subprogram 
> is known to Ada.  I'll assumme that Meridian Ada supports this...

Close, but not quite right for Meridian Ada.  The pragma is

    pragma interface ( <language> , <subprogram> [ , "<link -name>" ]

(In the Meridian Ada documentation for the Macintosh, it's on page 91.)
Thus you want

    procedure Clrscrn;
    pragma Interface(C, Clrscrn, "_Clrscrn");

Art Evans

Arthur Evans Jr, PhD        Phone: 412-963-0839
Ada Consulting              FAX:   412-963-0927
461 Fairview Road
Pittsburgh PA  15238-1933
evans@evans.pgh.pa.us




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1996-08-28  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-24  0:00 External C functions and ADA Joseph Fabian
1996-08-26  0:00 ` Jim Dorman
  -- strict thread matches above, loose matches on Subject: below --
1996-08-27  0:00 External C functions and Ada Mark Bell
1996-08-28  0:00 ` Arthur Evans Jr

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