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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: hreba Newsgroups: comp.lang.ada Subject: Re: How can one record component be local and another not? Date: Tue, 5 May 2020 19:17:40 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net eYEkQaXB8lcjdPLEXwzsZQhan0O9rfo4m5e/nYHwH66HaigRCo Cancel-Lock: sha1:yC0IOAt6EfAtZ+IENLSsDj4Sc0I= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 In-Reply-To: Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:58601 Date: 2020-05-05T19:17:40+02:00 List-Id: 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. -- Frank Hrebabetzky, Kronach +49 / 9261 / 950 0565