On 2013-07-11 06:21, Bruce Evans wrote: > On Wed, 10 Jul 2013, Garrett Wollman wrote: >> <<On Wed, 10 Jul 2013 22:12:59 +0200, Tijl Coosemans <tijl_at_freebsd.org> said: >>> I think isnan(double) and isinf(double) in math.h should only be >>> visible if (_BSD_VISIBLE || _XSI_VISIBLE) && __ISO_C_VISIBLE < 1999. >>> For C99 and higher there should only be the isnan/isinf macros. >> >> I believe you are correct. POSIX.1-2008 (which is aligned with C99) >> consistently calls isnan() a "macro", and gives a pseudo-prototype of >> >> int isnan(real-floating x); > > Almost any macro may be implemented as a function, if no conforming > program can tell the difference. It is impossible for technical reasons > to implement isnan() as a macro (except on weird implementations where > all real-floating types are physically the same). In the FreeBSD > implementation, isnan() is a macro, but it is also a function, and > the macro expands to the function in double precision: > > % #define isnan(x) \ > % ((sizeof (x) == sizeof (float)) ? __isnanf(x) \ > % : (sizeof (x) == sizeof (double)) ? isnan(x) \ > % : __isnanl(x)) The C99 standard says isnan is a macro. I would say that only means defined(isnan) is true. Whether that macro then expands to function calls or not is not important. > I don't see how any conforming program can access the isnan() function > directly. It is just as protected as __isnan() would be. (isnan)() > gives the function (the function prototype uses this), but conforming > programs can't do that since the function might not exist. I don't think the standard allows a function to be declared with the same name as a standard macro (it does allow the reverse: define a macro with the same name as a standard function). I believe the following code is C99 conforming but it currently does not compile with our math.h: ------ #include <math.h> int (isnan)(int a, int b, int c) { return (a + b + c); } ------
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:39 UTC