comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <eachus@mitre.org>
Subject: Re: Problem with pragmas
Date: 1999/06/30
Date: 1999-06-30T00:00:00+00:00	[thread overview]
Message-ID: <377A71D9.D175448A@mitre.org> (raw)
In-Reply-To: FE4vxK.20D@robkaos.ruhr.de

Robert Schien wrote:

> I need to access the erf (Gaussian error function) from the C-Math-Library.
> But the following program does not work correctly:

> 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?
 
    It could be a bug, or a library function that just hasn't been
implemented in that version of Unix.  But there is another possibility,
one of those fun C rules.  The C math libraries actually take double
parameters, and the C compiler converts from float if necessary.   In
fact all scalar floating point parameters are passed as double or in
floating point registers.  On arcitectures where floating point
parameters are passed in registers, you won't notice a problem.  (Then
why have C_float in Interfaces.C?  Because you will often have floats in
structs that you need to interface to.)  I'm not sure about FreeBSD-4.0,
but if the call sequence was defined so it would work on 386 chips or
earlier, the parameters may not be passed in registers.

    (It also might be a good idea for Ada compilers to warn when C
interfaces are declared with C_float parameters.  Sometimes it is right
for example for 
OS calls.  Also on most hardware the parameters will be passed in
floating point registers, so the compiler shouldn't force the change.)

-- 

                                        Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




      parent 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 Problem with pragmas Robert Schien
1999-06-30  0:00 ` David
1999-06-30  0:00 ` Florian Weimer
1999-07-01  0:00   ` Robert Schien
1999-06-30  0:00 ` Robert I. Eachus [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox