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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,65234f982d381bb8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-10 19:33:00 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!213.56.195.71!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "David Botton" Newsgroups: comp.lang.ada Subject: Re: Passing an Ada array to a C function Date: Mon, 10 Sep 2001 22:32:04 -0400 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <86772402.0109101721.26fc679a@posting.google.com> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1000175579 67581 137.194.161.2 (11 Sep 2001 02:32:59 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 11 Sep 2001 02:32:59 +0000 (UTC) To: Return-Path: X-pair-Authenticated: 216.254.101.195 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.4 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:13024 Date: 2001-09-10T22:32:04-04:00 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" Newsgroups: comp.lang.ada To: 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 >