comp.lang.ada
 help / color / mirror / Atom feed
From: "David Botton" <David@Botton.com>
To: <comp.lang.ada@ada.eu.org>
Subject: Re: Passing an Ada array to a C function
Date: Mon, 10 Sep 2001 22:32:04 -0400
Date: 2001-09-10T22:32:04-04:00	[thread overview]
Message-ID: <mailman.1000175530.9345.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: 86772402.0109101721.26fc679a@posting.google.com

procedure My_C_Func (S : Interfaces.C.char_array);
pragma Import (C, My_C_Func);

is equal to

void My_C_Func (char* s);

A Char_Array contains more information than a char* and does not per se
occupy the same number of bytes, but take a look at the ref manual where it
describes that compilers must make the above possible.

The Ada interface to C in most code and bindings I have seen highly
underused. There is all kinds of neat stuff you can do by just setting up
the procedure specs properly. Take a look at the body of some of the
GWindows packages (http://www.adapower.com/gwindows) for some good ideas. I
chose not to write a set stand alone thin Win32 bindings since that would
cripple the power of the Ada interface to C and instead tailored each import
spec in the function body to match what I wanted to accomplish.

David Botton



----- Original Message -----
From: "Lin" <lin@post.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Monday, September 10, 2001 9:21 PM
Subject: Passing an Ada array to a C function


> If an Ada array holds the pointers pointing to a String (char_array),
> how can I pass the Ada array to an C funtion with an array as formal
> parameter? Is the "char_array" of Ada occupies the same bytes as the
> "char" of C?
>
> Many thnks.
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
>




  reply	other threads:[~2001-09-11  2:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-11  1:21 Passing an Ada array to a C function Lin
2001-09-11  2:32 ` David Botton [this message]
2001-09-18 13:37   ` Thierry Bernier
     [not found]   ` <3BA74E07.60E105C2@fr.thalesgroup.com>
2001-09-20  2:31     ` David Botton
2001-09-20 12:07       ` Robert Dewar
replies disabled

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