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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7117a84edbedc116 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-15 19:56:25 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail From: "Steve" Newsgroups: comp.lang.ada References: <3e9b28f8$1_4@newsfeed> Subject: Re: Interfacing Ada with C X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: NNTP-Posting-Host: 12.211.13.75 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc52.ops.asp.att.net 1050461781 12.211.13.75 (Wed, 16 Apr 2003 02:56:21 GMT) NNTP-Posting-Date: Wed, 16 Apr 2003 02:56:21 GMT Organization: AT&T Broadband Date: Wed, 16 Apr 2003 02:56:21 GMT Xref: archiver1.google.com comp.lang.ada:36177 Date: 2003-04-16T02:56:21+00:00 List-Id: A different way of doing this: In Ada you should be able to use Interfaces.C.Pointers and then declare your procedure as follows: package Interface_Wide_String is new Interfaces.C.Pointers( Interfaces.C.size_T, Interfaces.C.WChar_T, Interfaces.C.WChar_Array, Interfaces.C.Wide_Nul ); procedure One( Name : in Interface_Wide_String.Pointer ); pragma Export( C, One ); Within procedure "One" you can use: myName : Wide_String := Interfaces.C.To_Ada( Interface_Wide_String.Value( Name ) ); If you need to look at the string as a wide string. I haven't tested this, but I think it will work (it compiles anyway). Steve (The Duck) "Paul Anderson" wrote in message news:3e9b28f8$1_4@newsfeed... > Hi: > > I have a need to interface an Ada library with a C program. > I am having trouble finding the best way to convert > strings between the two worlds. > > I have a declaration: > > procedure One(Name : in Wide_String); > pragma Export(C, One, "one"); > > When I compile I get: > > foo.ads:29:42: warning: type of argument "One" is unconstrained array > foo.ads:29:42: warning: foreign caller must pass bounds explicitly > > Fine, except how do I "pass bounds explicitly" when I call > this function in C? The prototype for this function in C > would normally be: > > void one(wide_string w); > > which doesn't have a slot for the bounds. So where does it > go? > > Alternatively, is there an different way of doing this that > avoids this problem? > > I am using gnat-3.15p. > > Thanks, > > Paul. >