You forgot to specify a return type of the function.
*duh!*
thank you!
Anyway there is something strange - maybe I just forgot everything about maths, but I can't believe it. I created a "trigonometry.dll" with some functions from math.h as mentioned above. To be sure I made no mistake, here is the C code again:
extern "C" __declspec(dllexport) double math_sin(double mynumber)
{
return sin(mynumber);
}
extern "C" __declspec(dllexport) double math_cos(double mynumber)
{
return cos(mynumber);
}
extern "C" __declspec(dllexport) double math_pow(double mynumber1, double mynumber2)
{
return pow(mynumber1,mynumber2);
}
The pow() function is just for test purposes - but useful anyway.
Now the script:
external "trigonometry.dll" cdecl double math_pow(double, double);
external "trigonometry.dll" cdecl double math_sin(double);
external "trigonometry.dll" cdecl double math_cos(double);
Game.Msg("sin(90) = " + math_sin(90));
Game.Msg("cos(90) = " + math_cos(90));
Game.Msg("pow(2,8) = " + math_pow(2,8));
The result:
pow(2,8) = 256.000000 (as expected!)
sin(90) = 0.893997 (what ?)
cos(90) = -0.448074 (
)
IMHO that's wrong! I'd expected them to be "0" and "1".
Changing the external lines to math_sin(int) or math_sin(float) didn't help, the values were wrong. I don't understand it !?