From: robsch@robkaos.ruhr.de (Robert Schien)
Subject: Problem with pragmas
Date: 1999/06/30
Date: 1999-06-30T00:00:00+00:00 [thread overview]
Message-ID: <FE4vxK.20D@robkaos.ruhr.de> (raw)
I need to access the erf (Gaussian error function) from the C-Math-Library.
But the following program does not work correctly:
with Ada.Float_Text_IO;
use Ada.Float_Text_IO;
with Ada.Text_IO;
use Ada.Text_IO;
with Interfaces.C;
use Interfaces.C;
procedure pragtest is
y: float;
c_y: C_float;
-- Accessing Gaussian error function
function erf (x: in C_float) return C_float;
pragma Import(C,erf);
begin
y:=0.3;
c_y:=c_float(y);
c_y:=erf(c_y);
y:=float(c_y);
put(y);
end pragtest;
This program is compiled and linked with the command
gnatmake pragtest.adb -largs -lm
But when I execute pragtest, the printed result is always 0.0.
(The correct result is something between 0 and 1, in this case
about 0.32)
What did I miss?
The platform is FreeBSD-4.0-current (x86) with GNAT 3.11p.
TIA
Robert
next reply other threads:[~1999-06-30 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-30 0:00 Robert Schien [this message]
1999-06-30 0:00 ` Problem with pragmas David
1999-06-30 0:00 ` Robert I. Eachus
1999-06-30 0:00 ` Florian Weimer
1999-07-01 0:00 ` Robert Schien
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox