comp.lang.ada
 help / color / mirror / Atom feed
* C++ and Ada
@ 1998-10-22  0:00 yuen3785
  0 siblings, 0 replies; 9+ messages in thread
From: yuen3785 @ 1998-10-22  0:00 UTC (permalink / raw)


If anyone out there has an example of calling exported Ada functions from C++,
I would appreciated.

I am trying to call a exported Ada function from Microsoft Visual C++.  When I
am trying to make a link, there are unresolved symbols from one of the Ada
library object file.  The name of the object file is min_tasking.a and is
provided by VADS Ada compiler without the source code.  I would like to find
out if there is a way to use only the symbols that I need and ignore the rest
of the symbols in the min_tasking.a.

Thank you
Wing


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




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

* C++ and Ada
@ 1998-10-22  0:00 yuen3785
  1998-10-23  0:00 ` Jerry van Dijk
  1998-10-23  0:00 ` Stephen Leake
  0 siblings, 2 replies; 9+ messages in thread
From: yuen3785 @ 1998-10-22  0:00 UTC (permalink / raw)


If anyone out there has an example of calling exported Ada functions from C++,
I would appreciated it.

I am trying to call a exported Ada function from Microsoft Visual C++.  When I
am trying to make a link, there are unresolved symbols from one of the Ada
library object file.  The name of the object file is min_tasking.a and is
provided by VADS Ada compiler without the source code.  I would like to find
out if there is a way to use only the symbols that I need and ignore the rest
of the symbols in the min_tasking.a file

Thank you
Wing

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

* Re: C++ and Ada
  1998-10-22  0:00 yuen3785
  1998-10-23  0:00 ` Jerry van Dijk
@ 1998-10-23  0:00 ` Stephen Leake
  1 sibling, 0 replies; 9+ messages in thread
From: Stephen Leake @ 1998-10-23  0:00 UTC (permalink / raw)


yuen3785@my-dejanews.com writes:

> If anyone out there has an example of calling exported Ada functions from C++,
> I would appreciated it.
> 
> I am trying to call a exported Ada function from Microsoft Visual C++.  When I
> am trying to make a link, there are unresolved symbols from one of the Ada
> library object file.  The name of the object file is min_tasking.a and is
> provided by VADS Ada compiler without the source code.  I would like to find
> out if there is a way to use only the symbols that I need and ignore the rest
> of the symbols in the min_tasking.a file

I haven't used VADS, but 'min_tasking.a' sounds like part of the
run-time system. Are you doing anything in Ada that requires tasking?
This includes explicit tasks, as well as delay statements.

You need to arrange for the Ada elaboration and finalization code to
be called from your C++ main. Consult your compiler documentation
about how to do that.

If you'll post the exact code and error messages, maybe we can be more
helpful.

-- Stephe




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

* Re: C++ and Ada
  1998-10-22  0:00 yuen3785
@ 1998-10-23  0:00 ` Jerry van Dijk
  1998-10-23  0:00 ` Stephen Leake
  1 sibling, 0 replies; 9+ messages in thread
From: Jerry van Dijk @ 1998-10-23  0:00 UTC (permalink / raw)


yuen3785@my-dejanews.com wrote:

: I am trying to call a exported Ada function from Microsoft Visual C++.  When I
: am trying to make a link, there are unresolved symbols from one of the Ada
: library object file.  The name of the object file is min_tasking.a and is
: provided by VADS Ada compiler without the source code.  I would like to find
: out if there is a way to use only the symbols that I need and ignore the rest
: of the symbols in the min_tasking.a file

Assuming you are using the MS linker, are you sure the min_tasking.a library
is a) in a MS compatible library format and b) is Win32 compatible ?

Jerry.

-- 
-- Jerry van Dijk  | email: jdijk@acm.org
-- Leiden, Holland | member Team-Ada
-- Ada & Win32: http://stad.dsl.nl/~jvandyk




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

* C and ADA
@ 2008-01-02 22:33 Brian
  2008-01-02 22:44 ` Harald van Dijk
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Brian @ 2008-01-02 22:33 UTC (permalink / raw)


Hi I have an ADA function that I'd like to call from my C program.

Is there any way to provide a .h file containing a C prototype for the
ADA function and then link the ADA with the C? Does anyone have any
experience of this?

I'm using a GNU setup on Linux.

Thanks.




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

* Re: C and ADA
  2008-01-02 22:33 C and ADA Brian
@ 2008-01-02 22:44 ` Harald van Dijk
  2008-01-02 22:47 ` Keith Thompson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Harald van Dijk @ 2008-01-02 22:44 UTC (permalink / raw)


On Wed, 02 Jan 2008 23:33:10 +0100, Brian wrote:
> Hi I have an ADA function that I'd like to call from my C program.
> 
> Is there any way to provide a .h file containing a C prototype for the
> ADA function and then link the ADA with the C? Does anyone have any
> experience of this?

C doesn't define how to mix C with other languages. I believe Ada does 
define how to mix Ada with other languages, so you're better off asking 
in an Ada newsgroup.



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

* Re: C and ADA
  2008-01-02 22:33 C and ADA Brian
  2008-01-02 22:44 ` Harald van Dijk
@ 2008-01-02 22:47 ` Keith Thompson
  2008-01-02 23:09 ` Lucretia
  2008-01-03  7:38 ` Jerry
  3 siblings, 0 replies; 9+ messages in thread
From: Keith Thompson @ 2008-01-02 22:47 UTC (permalink / raw)


Brian <nospam@nospam.invalid> writes:
> Hi I have an ADA function that I'd like to call from my C program.
>
> Is there any way to provide a .h file containing a C prototype for the
> ADA function and then link the ADA with the C? Does anyone have any
> experience of this?
>
> I'm using a GNU setup on Linux.

Ada (not "ADA"; it's not an acronym) provides mechanisms for
cross-language calls between Ada and C; C does not.  The folks in
comp.lang.c won't be able to answer your question.  I've redirected
followups just to comp.lang.ada, and I suggest that others do
likewise.

-- 
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
[...]
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"



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

* Re: C and ADA
  2008-01-02 22:33 C and ADA Brian
  2008-01-02 22:44 ` Harald van Dijk
  2008-01-02 22:47 ` Keith Thompson
@ 2008-01-02 23:09 ` Lucretia
  2008-01-03  7:38 ` Jerry
  3 siblings, 0 replies; 9+ messages in thread
From: Lucretia @ 2008-01-02 23:09 UTC (permalink / raw)


On Jan 2, 10:33 pm, Brian <nos...@nospam.invalid> wrote:
> Hi I have an ADA function that I'd like to call from my C program.
>
> Is there any way to provide a .h file containing a C prototype for the
> ADA function and then link the ADA with the C? Does anyone have any
> experience of this?
>
> I'm using a GNU setup on Linux.
>
> Thanks.

You can add a "pragma Export" to your procedure and compile it with
gnat. There is a chapter on mixed language programming in the GNAT
manual. But I think you might end up having to build the app with
gnat. Surely porting the procedure would be easier?

Luke.



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

* Re: C and ADA
  2008-01-02 22:33 C and ADA Brian
                   ` (2 preceding siblings ...)
  2008-01-02 23:09 ` Lucretia
@ 2008-01-03  7:38 ` Jerry
  3 siblings, 0 replies; 9+ messages in thread
From: Jerry @ 2008-01-03  7:38 UTC (permalink / raw)


On Jan 2, 3:33 pm, Brian <nos...@nospam.invalid> wrote:
> Hi I have an ADA function that I'd like to call from my C program.
>
> Is there any way to provide a .h file containing a C prototype for the
> ADA function and then link the ADA with the C? Does anyone have any
> experience of this?
>
> I'm using a GNU setup on Linux.
>
> Thanks.

This process is described here (as well as the opposite process where
the main program is Ada);

http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Interfacing-to-C.html#Interfacing-to-C


Also, see the Ada Reference Manual:

http://www.adaic.com/standards/05rm/html/RM-B-3.html


FWIW, I've done this sort of thing using GPC, the GNU Pascal compiler,
with good results.

Jerry



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

end of thread, other threads:[~2008-01-03  7:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-02 22:33 C and ADA Brian
2008-01-02 22:44 ` Harald van Dijk
2008-01-02 22:47 ` Keith Thompson
2008-01-02 23:09 ` Lucretia
2008-01-03  7:38 ` Jerry
  -- strict thread matches above, loose matches on Subject: below --
1998-10-22  0:00 C++ and Ada yuen3785
1998-10-22  0:00 yuen3785
1998-10-23  0:00 ` Jerry van Dijk
1998-10-23  0:00 ` Stephen Leake

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