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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: How can one record component be local and another not? Date: Tue, 5 May 2020 22:08:36 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net l8CkX9sOGHszTFMLZ1WqrghkSQR609i/c1ybDxCU6V/q1D0/pA Cancel-Lock: sha1:zDiLZr+ILAhkLyrKXlMc5Vrji7A= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 In-Reply-To: Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:58604 Date: 2020-05-05T22:08:36+03:00 List-Id: On 2020-05-05 20:17, hreba wrote: > On 5/5/20 5:45 PM, Jeffrey R. Carter wrote: >> On 5/5/20 1:04 PM, hreba wrote: >>> >>> (The reason for the above construction is the need to pass a pointer >>> to a C library function.) >> >> Most likely you do not need to pass a pointer to your C function. For >> example, given the C function >> >> void f (int* i); >> >> You can do >> >> procedure F (I : in out Interfaces.C.int) with Import, Convention => >> C, ...; >> >> and the compiler will call the C function correctly. >> > > It is more complicated, unfortunately. I got > >    type gsl_odeiv2_system is record >       c_function : access function >            (arg1 : double; >             arg2 : access double; >             arg3 : access double; >             arg4 : System.Address) return int;  -- > /usr/include/gsl/gsl_odeiv2.h:58 >       jacobian : access function >            (arg1 : double; >             arg2 : access double; >             arg3 : access double; >             arg4 : access double; >             arg5 : System.Address) return int;  -- > /usr/include/gsl/gsl_odeiv2.h:60 >       dimension : aliased size_t;  -- /usr/include/gsl/gsl_odeiv2.h:61 >       params : System.Address;  -- /usr/include/gsl/gsl_odeiv2.h:62 >    end record; >    pragma Convention (C_Pass_By_Copy, gsl_odeiv2_system);  -- > /usr/include/gsl/gsl_odeiv2.h:64 > > and I have to pass a variable >    sys: access gsl_odeiv2_system > to the initialization function of that C library, and the > >   params: System.Address; > > component in the record, which internally is then passed to c_function() > and jacobian(), posed the problem. I don't understand -- System.Address is not an access type; why do you need to use an access type to produce this parameter? Do you need a pointer to the "params" component? Perhaps you can show a bit more of the actual code that has the problem? -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .