It depends on which title you include. If you include the C <math.h> header (which is part of C ++, although marked as deprecated), you can use unqualified C functions, such as isnan . If you, on the other hand, include the C ++ <cmath> header, you guarantee that it will bring all functions from <math.h> to the std , and therefore you must qualify them correctly, for example std::isnan (or use some kind of using directive). Unfortunately, the implementation is allowed, but it is not required to include these functions in the global namespace when <cmath> included (and, thus, this is one of many "works on my machine") - C ++ features and the reason why many people write code like you just tried to compile unsuccessfully).
So, summarize: either turn on <math.h> , or use isnan or turn on <cmath> and use std::isnan , everything else is not portable. Of course, all this applies to any other C header and its corresponding C ++ version.
EDIT: It should be noted that this particular isnan function is isnan supported with C ++ 11 and is not available at all in C ++ 98 (which may be part of your confusion). But that doesn’t change anything in this situation, because in C ++ 98 neither <cmath> nor <math.h> (which was the actual C89 / C90 header, and then, and not the C99 header, which includes C ++ 11 ), there was this function, since they are always synchronized. So maybe this library from your question was trying to use C ++ 98, accepting the isnan function from another C99 implementation (which is not a good idea, since it might contradict parts of C89 / C90 C ++, they didn’t even try to do this) .
source share