Add isnan function.

Merged
#7 · Created  · Last updated

Merged pull request

Merged in de-vri-es/trac_ik/isnan (pull request #7)

95bd941·Author: ·Closed by: ·2016-02-25

Description

A recent system update made trac_ik_lib/src/nlopt_ik.cpp fail to compile due to the non-existence of isnan.

I assume it was pulled in indirectly from <math.h>. However, including C headers directly is not the most elegant thing to do, and it can cause strange problems when certain macros are imported into the global namespace.

The alternative #include <cmath> only contains std::isnan since C++11 [1], so unless the project already requires C++11 it seems a stupid thing to add a C++11 requirement for (I didn't check, if it does, std::isnan would be the best option).

Instead I opted to implement bool isNan() for floats and doubles. I did not call it isnan in case <math.h> is still pulled in on some systems, since isnan is allowed to be a macro [2] (which would break the function definition horribly if it used the same name).

I put the two functions in an anonymous namespace to prevent any possibility of (future) linking errors.

0 attachments

0 comments

Loading commits...