SimpleIDE question: isinf?

I'm trying to use isnan and isinf. In the code below, isnan works, but if I uncomment the line with isinf, the compiler gives me an "undefined reference to '___isinf" error.
#include "simpletools.h"

int main() {
  print("%d\n", isnan(sqrt(-2))); // prints 1
//  print("%d\n", isinf(sqrt(-2)));
}
I am using 64-bit doubles.

What's the secret to using isinf??

Comments

  • Dave HeinDave Hein Posts: 6,062
    edited 2020-07-10 - 22:04:36
    I believe isinf() is defined as a macro in math.h. Add "#include <math.h>", and it should work.

    EDIT: I tested with GCC under cygwin, and it works OK. However, it fails with PropGCC. You'll have to define isinf() yourself. There are examples on the internet of how to do it. An infinite value has all ones for the exponent and all zeros for the mantissa.
  • Thanks, @Dave Hein

    I did write my own isinf, but I'm still curious as to why isinf doesn't work. After all, isnan is also a macro in math.h and it works, so what's up with isinf???
  • I looked at math.h in the include directory, and it defines isinf to be ___isinf for doubles, and ___isinff for floats. It does a similar thing for isnan. So then I did a "nm libm.a" in the lib directory, and I found ___isnanf and ___isnanff, but it did not contain ___isinf or ___isinff. This is the cause of the linker error. Supplying your own ___isinf fixes the problem.
  • Well, sure, that's a fix... but istm that the real fix is for someone to rebuild libm.a and not forget ___isinf this time.

    Is anyone maintaining this stuff?
  • Is anyone maintaining this stuff?
    NOPE! Since SimpleIDE is open source, I guess we are supposed to maintain it ourselves. Isn't that the big attraction of open source software, you get to maintain it yourself.

    Ray
  • Rsadeika wrote: »
    Is anyone maintaining this stuff?
    NOPE! Since SimpleIDE is open source, I guess we are supposed to maintain it ourselves. Isn't that the big attraction of open source software, you get to maintain it yourself.

    Ray

    Lol ain't that the sad truth.

    @mpark, you could try opening a ticket at https://github.com/totalspectrum/proplib/ and reporting the problem.
    Unfortunately, for a variety of reasons, SimpleIDE and PropGCC are not being maintained anymore.
Sign In or Register to comment.