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 X-Google-Thread: 103376,96ffd854e360102b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-19 00:13:48 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!newsgate.cistron.nl!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail From: gerhard.nospam@bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Newsgroups: comp.lang.ada Subject: Re: Calling C's fopen from Ada (Aonix compiler) Date: Tue, 19 Dec 2000 08:54:32 +0100 Organization: T-Online Message-ID: References: <3A357C48.D4CAC970@nowhere.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.t-online.com 977213295 07 15733 jxcdNNbS-apw1 001219 08:08:15 X-Complaints-To: abuse@t-online.com X-Sender: 320066699498-0001@t-dialin.net User-Agent: slrn/0.9.6.2 (Linux) Xref: supernews.google.com comp.lang.ada:3241 Date: 2000-12-19T08:54:32+01:00 List-Id: I think the error is that you used Char_Array where Interfaces.C.Chars_Ptr should be used. So the compiler passes the arguments to fopen in by-value instead of by-reference mode. IMO, an interface to fopen should be something like: ------------------------------------------------------------------------- WITH Interfaces.C.Strings; USE Interfaces.C.Strings; PACKAGE FO_Wrapper IS SUBTYPE File_Ptr IS chars_ptr; FUNCTION fopen( name: chars_ptr; mode: chars_ptr ) RETURN File_Ptr; PRAGMA Import( C, fopen, "fopen" ); END FO_Wrapper; ------------------------------------------------------------------------- Gerhard H�ring On Mon, 11 Dec 2000 19:15:52 -0600, Wayne Magor wrote: >I need to call a C procedure which requires a file pointer (the file >must be opened by >the caller). So I want to call C's fopen from Ada (I'm using the Aonix >Ada compiler on >Windows NT). > >This causes an access error exception in the program that requires the >file pointer, however, [snip] > package C renames Interfaces.C; > > F : File_Ptr; > [snip] > function fopen (Name : in C.Char_Array; > Mode : in C.Char_Array) return File_Ptr; > pragma Import (C, fopen, "fopen"); > -- mail: gerhard bigfoot de web: http://highqualdev.com