comp.lang.ada
 help / color / mirror / Atom feed
* Re: Linking an ADA routine to a program written in C
@ 1996-10-04  0:00 Larry Kilgallen
  1996-10-08  0:00 ` Robert Dewar
  0 siblings, 1 reply; 14+ messages in thread
From: Larry Kilgallen @ 1996-10-04  0:00 UTC (permalink / raw)



In article <dewar.844372753@schonberg>, dewar@schonberg.cs.nyu.edu (Robert Dewar) writes:
> Larry says
> 
> "> However, in practice, since Ada 95 can duplicate a C interface, Ada 95
>> can certainly interfac to anything that C (or for that matter Fortran
>> or COBOL) can interface to. Of course, as is generally true for interacing
>> from C to anything, such interfaces may indeed be non-portable.
> 
> As far as _non-portable_ interfaces to other languages, I can do that
> with an Ada 83 program, since I can generally figure out how to program
> in assembly language, and in my experience understanding the underlying
> machine calling sequences is essential for figuring such things out even
> if the linkage is to be constructed in a compiled language.
> "

> This shows that you do not have muych experience in the use of Ada 95 in
> constructing such interfaces, since what you say is simply wrong for
> Ada 95, you can interface GNAT to a wide range of languages by following
> whatever C would do without having the slightest idea of what the
> underlying machine calling sequence is.

And how do I find out "whatever C would do" ?

Are you presuming that every Ada programmer is a former C programmer ?

The little bit of C I do know does not seem to support that
portability argument.  VMS C programmers call to Pascal routines
without specifying that the language being called is Pascal.
When they port that C code to 68K Macintosh, they must add
a keyword to their source to indicate that the language being
called is Pascal.  Presumably any Ada implementation must deal
with that issue as well, but adding a keyword on getting to a
new platform is not what I would call portable.

Or even consider calling out to C programs.  I buy object
code which was written in C from one vendor.  If I were to
buy different object code from another vendor who happened
to use a different brand of 68K Macintosh C compiler (there
are 4 available at last count), I would have to specify in
my Ada program which brand of C was used for the various
imported C subroutines, since there are different binary
calling conventions for the various brands of C compiler.
This is not an issue on VMS (unless gcc has managed to
avoid using the common calling standard), so the Ada code
I had written on VMS would need to be "augmented" in order
to work on 68K Macintosh.

Now admittedly, I only have one current vendor from whom
I get multi-platform subroutines written in C.  I am sure
there are other vendors selling software in that format,
but it is unlikely their subroutines are something I want.

> Perhaps your experience with Ada 83 is indeed typical, perhaps it is
> not, but in any case it seems irrelevant with respect to Ada 95.

Presentation of such a broad marketing claim seems intended to win me
over on our previous discussions regard GNAT being "commercial" :-)

Larry




^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Linking an ADA routine to a program written in C
@ 1996-09-28  0:00 Robert Dewar
  1996-09-28  0:00 ` Larry Kilgallen
  0 siblings, 1 reply; 14+ messages in thread
From: Robert Dewar @ 1996-09-28  0:00 UTC (permalink / raw)



Larry said

"I seem to recall about 5 languages being listed in the standard,
which hardly clarifies as "most", especially since it leaves out
some of my favorites :-)."

Actually only 3 languages are mentioned epxlicitly, and the claim should
have said "interface with most other standardized languages". Obviously
the ISO standard for Ada 95 cannot talk about nonstandardized languages
like C++ Java, or whatever.,

However, in practice, since Ada 95 can duplicate a C interface, Ada 95
can certainly interfac to anything that C (or for that matter Fortran
or COBOL) can interface to. Of course, as is generally true for interacing
from C to anything, such interfaces may indeed be non-portable.





^ permalink raw reply	[flat|nested] 14+ messages in thread
* Linking an ADA routine to a program written in C
@ 1996-09-18  0:00 newmans
  1996-09-18  0:00 ` Larry Kilgallen
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: newmans @ 1996-09-18  0:00 UTC (permalink / raw)




I desperately need an explanation of how to link a routine written and compiled in ADA into a program
written in C.  For example, I built an ada  test procedure hello.a and compiled it using the ada compiler.
The object file produced was called hello01.  This program uses TEST_IO package to do the output.

Since the object module hello01 is ELF-32 bit I linked it in with my C objects using gcc.  But of course,
I get undefined symbols because I have no idea how to tell gcc about the TEST_IO package.  

Does anyone know how this can be done.  

Also, some people have mentioned that I may have to use a PRAGMA in my C code to tell the
compiler that the  routine I am calling  i.e. "hello"  is not a C subroutine.  C passes arguments from
right to left.  I believe ADA probably passes them like PASCAL from left to right.  In C you can declare
a routine to be type pascal to change the calling sequence to match PASCAL's.  If anyone has
any experience calling ADA routines from C please contact me ASAP. 

		Thank you! 




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

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

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-04  0:00 Linking an ADA routine to a program written in C Larry Kilgallen
1996-10-08  0:00 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1996-09-28  0:00 Robert Dewar
1996-09-28  0:00 ` Larry Kilgallen
1996-10-03  0:00   ` Robert Dewar
1996-09-18  0:00 newmans
1996-09-18  0:00 ` Larry Kilgallen
1996-09-19  0:00 ` David C. Hoos, Sr.
1996-09-19  0:00   ` Larry Kilgallen
1996-09-20  0:00     ` Calius
1996-09-20  0:00       ` Chris Brand
1996-09-24  0:00   ` Cyrille Comar
1996-09-25  0:00     ` Larry Kilgallen
1996-09-26  0:00 ` Jens Jakob Jensen

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