[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Eric Botcazou wrote:
float c = cos(a);
is expanded as:
float c = float(cos (fix(a)));
What? Excuse me? What compiler is this? That makes no sense. Why
would it be doing that? cos doesn't even TAKE a fix value. Why would
the compiler convert the value to fix and convert it back to float?
That makes NO sense. If anything that should be a compiler problem!
The only time it should implicitly convert is if you called fcos or the
Allegro fixed functions, but even then that's sketchy as Allegro's
functions don't take fix, they take fixed, and the compiler shouldn't do
a double implicit conversion.
Unless I don't understand something here, there's something wrong with that.
Hmm I just read that including math.h solves this? That makes no sense,
either. If you didn't include math.h, who defined cos? Why does that
even compile?
I'd rather mark the constructors as explicit:
I think that we shouldn't make it explicit. It would break backwards
compatability, and I'm not sure that that's the problem. If it only
fails when someone didn't declare cos because they didn't #include
math.h it's not an allegro problem. I just encountered a problem the
other day with implicit declarations in C and not including a headerfile
just made errors everywhere with functions returning strange values, or
returning constant values regardless of input, even when you print out
the variable right before you return it. Making the conversions
explicit won't help against incorrect compilers or incorrect source
code, whichever one is the culprit here.
Gillius