Reputation: 1793
I am observing some behavior for which I am finding it tough to reason.
I have a piece of code as follows:
int timer_temp_var;
if ((timer_temp_var/1000.0) > 5.0)
{
//Do something
}
This piece leads to link error.
>
> dld: warning: Undefined symbol _d_fle"
> dld: no output written make[1]: ***
> [app.elf] Error 1
But on replacing the equality check as :
if ((timer_temp_var/1000.0) < 5.0) // replace '>' with '<'.
I see no issues.
Also instead of doing division by 1000.0 if I do by 1000 as follows:
if ((timer_temp_var/1000) > 5)
{
//Do something
}
I see no issues irrespective of the kind of equality check.
The application is compiled to run on a pSOS operating system.
What is the reason for such a behavior?
Upvotes: 1
Views: 1310
Reputation: 27573
You are missing a floating-point library. Try including the math library (libm.a) and see if that does the trick.
Upvotes: 1
Reputation: 34958
Seems your compiler replaces ">" operator with call to _d_fle()
function, so you need to link some library to your executable.
Surprisingly "<" works although it should be replaced with d_fgt()
function that most likely to be located in the same lib.
Changing from 100.0
to 100
makes left operand of ">" integer and it seems integer comparison doesn't require any function calls - probably it gets compiled to CPU instruction rather than function call.
EDIT: Looks like you need SFPE (software floating-point emulation) library. Do you have anything like libsfpe ?
Upvotes: 2
Reputation: 3138
The change from 1000.0 to 1000 suggest problem with floating point operation. Try cast 1000.0 to (int) and see if you have any progress.
Changing the sign < to > sounds not reasonable to lead to any changes...
Upvotes: 1