|
From: Hans-Bernhard B. <HBB...@t-...> - 2016-02-16 01:07:16
|
Am 15.02.2016 um 23:31 schrieb sfeam: > I am having trouble to understand how in our particular case C++ can > fail to find the C language definition of isnan() from <math.h> > > and <math.h> as I understand it is required to define isnan() by C99. It would be. _But_ we're not running a C99 compiler here; we're running a C++ compiler. Now a C++11 compiler would be required (C++1x 26.8p3,p4) to effectively pull in the C99 version of <math.h>, including isnan(), except that in C++ it's not a macro: it's a set of three overloaded functions. C++ really doesn't want macros for this sort of thing. A compiler that's not running in C++11 mode (or equivalent) is not only not required to do that: it's even kind-of forbidden. Earlier editions of the C++ standard explicitly listed which functions <math.h> shall bring into a C++ program's global name space (C++03 26.5p1,p2). isnan() was not among them. To overcome this limit might take an equivalent of what the AC_USE_SYSTEM_EXTENSIONS method of autoconf does for us about the difference between "strict" and "extended" C, but for C++. > So why does the C++ compiler not pick up the C99 macro even if > it wouldn't otherwise define it on its own? Because the header itself hides it from C++'s view, probably by querying (__STDC_VERSION__ >= 199901L) and/or (__cplusplus >= 201103L) > If it's only this one place, may the simplest work-around is: > - if (isnan(*image)) > + if (*image != *image) // this test works even if isnan() is missing That might well be the case. |