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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,91d8782d7d7e9c57 X-Google-Attributes: gid103376,public From: Matthew Kennedy Subject: Why doesn't an access to an imported C function work? Date: 1997/08/21 Message-ID: <33FAF8F1.431@mail.connect.usq.edu.au>#1/1 X-Deja-AN: 265495793 Organization: University of Southern Queensland Reply-To: q957722@mail.connect.usq.edu.au Newsgroups: comp.lang.ada Date: 1997-08-21T00:00:00+00:00 List-Id: Hello, My appended sample program refuses to compile at the line where Random := Random_Gaussian'Access; Where Random_Gaussian is a C function to be imported into Ada. I was wondering wether Ada supported access to imported C functions (I know it supports access to Ada function types) at all? It is important that the original C-source cannot be modified. ------------------------------------------------------------ with Ada.Float_Text_Io, Ada.Numerics, Text_Io, Interfaces.C; use Ada.Float_Text_Io, Ada.Numerics, Text_Io, Interfaces.C; procedure Function_Access is function Random_Gaussian(X : in Double) return Double; function Random_Uniform(X : in Double) return Double; pragma Import(C, Random_Gaussian, "RandomGaussian"); pragma Import(C, Random_Uniform, "RandomUniform"); type Function_Access is access function (X: in Double ) return Double; Random : Function_Access; procedure Evaluate(F : Function_Access; X : in Double; Y : out Double) is begin Y := F(X); end Evaluate; X, Y : Double; begin Random := Random_Gaussian'Access; X := 1.0; Y := Random(X); -- Evaluate(F'Access, X, Y); Put(Item => X); New_Line; Put(Item => Y); New_Line; end Function_Access; -- Matthew Kennedy Student of Electrical & Electronics Engineering University of Southern Queensland, Australia