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 X-Received: by 2002:a05:620a:1326:: with SMTP id p6mr5366106qkj.373.1588706381543; Tue, 05 May 2020 12:19:41 -0700 (PDT) X-Received: by 2002:aca:d68a:: with SMTP id n132mr80352oig.119.1588706381141; Tue, 05 May 2020 12:19:41 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 5 May 2020 12:19:40 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=70.109.61.2; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 70.109.61.2 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: How can one record component be local and another not? From: Jere Injection-Date: Tue, 05 May 2020 19:19:41 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:58605 Date: 2020-05-05T12:19:40-07:00 List-Id: On Tuesday, May 5, 2020 at 1:17:42 PM UTC-4, 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. > > -- > Frank Hrebabetzky, Kronach +49 / 9261 / 950 0565 This isn't so much a question for you directly...maybe more for those more experienced with the RM, but I was curious about the implications of having an "aliased" parameter inside a record with a C convention specified. For some reason, I thought that the aliased keyword implied a certain alignment in Ada (not necessarily in C) and didn't know if specifying the convention undid that alignment or if there is a risk of the record not always being the same layout/alignment as the expected C struct for the aliased parameter.