In <https://www.opengroup.org/sophocles/show_mail.tpl?CALLER=index.tpl&source=L&listname=austin-group-l&id=9979> Geoff Clare reported that the glibc implementations of <math.h> and <fenv.h> do not conform to C99 or to POSIX, because they define some macros using techniques that do not work inside #if, but C99 and POSIX require that the macros work in #if. I'll attach a patch against glibc head.
Created attachment 1395 [details] fix math.h, fenv.h macros to be usable in #if
I don't want to change this. It's a pointless requirement which just makes it harder to debug programs since the macros might not be available in the debug info.
Created attachment 1411 [details] fix math.h, fenv.h macros to be usable in #if (without removing enums) Here is a revised patch. This keeps the enums, so ordinary gcc -g compiles will have the names in the debug symbol table. This should overcome the objection to the original patch.
That is just calling for trouble. The requirement is unnecessary and most probably just an oversight. It makes no sense to have these as macros. The best way is to change the requirement in the spec so that this desease isn't spreading further.
Reopening. We discussed this on #glibc last night. We want a fix that avoids duplicating the numeric value of each macro; that is, something along the lines of (inside the enum): #define __FE_WHATEVER 0x100 FE_WHATEVER = __FE_WHATEVER, #define FE_WHATEVER __FE_WHATEVER
Check <bits/confname.h> as well, it does the enum like: _PC_MAX_CANON, #define _PC_MAX_CANON _PC_MAX_CANON this should work similar for fenv.h
ignore my last comment, I see the difference...
How about this instead? FE_WHATEVER = #define FE_WHATEVER 0x100 FE_WHATEVER, This repeats the number just once and the identifier just thrice, with no need for __FE_WHATEVER. It's odd, but I've seen odder.
I think that would be fine as well.
math.h fixed, following the approach suggested in comment 8, by: commit 0155d5b26e32b2012d9f1842c3b06324746d3087 Author: Joseph Myers <joseph@codesourcery.com> Date: Fri Nov 2 22:11:21 2012 +0000 Make math.h FP_* macros usable in #if (bug 3439). fenv.h still needs fixing.
fenv.h fixed for 2.17 by: commit fbeafedeea37e0af1984a6511018d159f5ceed6a Author: Joseph Myers <joseph@codesourcery.com> Date: Sat Nov 3 17:07:56 2012 +0000 Make fenv.h FE_* macros usable in #if (bug 3439).