Geoff Clare reported some conformance issues with glibc headers that
define some macros using techniques that do not work inside #if, even
though C99 and POSIX require that the macros work in #if. I recently
reported some of them against the math component (glibc bug 3439).
locale.h has some issues too, though, with macros like LC_ALL.
I'll attach an (untested but obvious) patch against glibc head.
Created attachment 1396 [details]
patch for LC_ALL etc. 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.
But this patch does not make it harder to debug programs, since it is already
the case that macros like LC_ALL are typically unavailable in the debug info.
<locale.h> has "#define LC_ALL __LC_ALL", and unless you use something like
gcc -g3, gdb won't see the LC_ALL.
If you like, I can rework the patch so that macros like __LC_ALL are
available in the debug info, but I doubt whether any normal users would
care so I don't see the point.
A better possibility is to rework this patch so that LC_ALL is typically
available in the debug info, while still conforming to C99 and POSIX.
This would require changing locale.h as well. I can submit that patch
if you prefer.
(The patches for math.h and fenv.h -- bug 3439 -- are in a different category;
I'll look at them a bit later.)
More of this macro nonsense.
Reopening. We discussed this general issue on #glibc last night. Paul, could you update your patch for current glibc and send it to libc-alpha for review?
(Note: I have not checked if any standard C headers other than those mentioned in this bug and bug 3439 are affected by similar issues. And I have not checked if POSIX has the same requirement for integer constant expression macros in POSIX headers, or what bugs there might be in POSIX headers if so.)
Author: Paul Eggert <email@example.com>
Date: Thu May 10 12:38:09 2012 +0000
[PATCH] [BZ #3440] Make LC_ALL etc. useful in #if expressions.