[AD] C++ fix math

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I don't know much C++, so I'm not sure this really needs fixing, but
on #allegro someone just had the following problem:

Given this C++ program:

#include <allegro.h>
#include <stdio.h>

int main()
{
 float a = 1;
 float c = cos (a);
 printf ("%f\n", c); 
 return 0;
}
END_OF_MAIN();

It will compile, even when using -Wall -W --pedantic --ansi and not
show a single warning.
But the result it prints is:

0.999695

By just not including allegro.h, the result becomes:

0.540302
(and a warning..)

The problem is, allegro's fix class will somehow auto-convert the
float and use the fixed float.. (as i said, i'm not sure how it
works)

Including <math.h> solves the problem of course. But considering
there is no warning about it, my proposed fix would be adding #include
<math.h> into fix.h, it would make cos always work i think.

--
Elias Pschernig



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/