definition looks similar to this (within RAMSES/RASS):
DEFINITION FOR C MODULE CMath;
PROCEDURE sqrt(x : LONGREAL) : LONGREAL;
PROCEDURE sin (x : LONGREAL) : LONGREAL;
PROCEDURE cos (x : LONGREAL) : LONGREAL;
PROCEDURE exp (x : LONGREAL) : LONGREAL;
PROCEDURE log (x : LONGREAL) : LONGREAL;
PROCEDURE atan(x : LONGREAL) : LONGREAL;
END CMath.
PROCEDURE Sin(x: REAL): REAL;
BEGIN
RETURN CMath.sin(x)
^^^
END Sin;
I think there might be a portability problem with the above (in gm2) -
as the C function sin is defined to take and return a 'double' whereas
in gm2 LONGREAL maps onto a 'long double'.
cut from 'man 3 sin':
#include <math.h>
double sin(double x);
float sinf(float x);
long double sinl(long double x);
I guess it works on systems where sizeof(double)==sizeof(long double)
or with Modula-2 compilers where TSIZE(LONGREAL)==sizeof(double). But
it will fail with gm2 as
LONGREAL == long double
REAL == double
SHORTREAL == float
For example:
address@hidden:~/GM2$ gm2 -g -fcpp -c sizes.mod
address@hidden:~/GM2$ gm2 -g -fcpp sizes.mod
address@hidden:~/GM2$ ./a.out
size of CHAR is 1 bytes
size of INTEGER is 4 bytes
size of CARDINAL is 4 bytes
size of LONGINT is 8 bytes
size of LONGCARD is 8 bytes
size of SHORTREAL is 4 bytes
size of REAL is 8 bytes
size of LONGREAL is 16 bytes
size of BITSET is 4 bytes
address@hidden:~/GM2$ gcc sizes.c
address@hidden:~/GM2$ ./a.out
size of char is: 1 bytes
size of int is: 4 bytes
size of unsigned int is: 4 bytes
size of long int is: 8 bytes
size of long unsigned int is: 8 bytes
size of long long int is: 8 bytes
size of long long unsigned int is: 8 bytes
size of float is: 4 bytes
size of double is: 8 bytes
size of long double is: 16 bytes
So specifically at position "^^^" we see that gm2 will attempt to pass
a "long double" parameter to a C function expecting a "double"
regards,
Gaius
--
________________________________________________________________________
Dr. Andreas Fischlin, Ph.D., Group Director
Terrestrial Systems Ecology
Institute of Integrative Biology: Ecology, Evolution, Infectious Disease
Department of Environmental Sciences, ETH Zurich
Address:
ETH Zurich, CHN E21.1
8092 Zurich, Switzerland
Phone: +41 44 633-6090 / Fax: +41 44 633-1136
http://www.sysecol.ethz.ch/Staff/af/
http://www.sysecol.ethz.ch/
_/_/_/ _/_/_/ _/ _/
_/ _/ _/ _/ Eidgenoessische Technische Hochschule Zuerich
_/_/_/ _/ _/_/_/ Swiss Federal Institute of Technology Zurich
_/ _/ _/ _/ Ecole polytechnique federale de Zurich
_/_/_/ _/ _/ _/ Politecnico federale de Zurigo
Make it as simple as possible, but distrust it!
________________________________________________________________________