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!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: hreba Newsgroups: comp.lang.ada Subject: Re: Interfaces.C questions Date: Sun, 19 Mar 2017 19:39:02 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 3jSoNfmyz3Rtc/F2LjGdwAo/knGXKWY5WI1hQ5/g0IumWXexMD Cancel-Lock: sha1:UhvRxsrUw+knv2syWwNWeyNlnmk= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:46425 Date: 2017-03-19T19:39:02+01:00 List-Id: A crude, pure interface version for a GSL quadrature function works. Now I have unexpected difficulties with a wrapper, which is a generic package: generic type Real is digits <>; type Parameters is private; package GSL is type Real_Function is access function (x: Real) return Real; ... The package body contains the following lines, everything on library level: type GSL_Function is record func: access -- this is line 21 function (x: C.double; params: Void_Ptr) return C.double; params: Void_Ptr; end record; pragma Convention (C, GSL_Function); real_func: Real_Function; ----%<---------------------------------------------------------- function func (x: C.double; params: Void_Ptr) return C.double is begin return C.double (real_func (Real(x))); end func; pragma Convention (C, func); -- this is line 37 Later, within a procedure body: gslf: aliased GSL_Function; begin gslf.func:= func'Access; -- this is line 66 ... I get the following compiler messages and understand nothing: gsl.adb:37:04: pragma "CONVENTION" requires separate spec and must come before body gsl.adb:66:19: subprogram "func" has wrong convention gsl.adb:66:19: does not match access to subprogram declared at line 21 - Separate spec? How? Before body? All my other CONVENTION pragmas come after the subprogram body, without any problem. - No match? Where is the difference? -- Frank Hrebabetzky +49 / 6355 / 989 5070