Description of problem: When _BSD_SOURCE is defined, <ctype.h> defines extraneous macros such as BIG_ENDIAN. Version-Release number of selected component (if applicable): glibc-2.3.5-10 Steps to Reproduce: Compile the following: #define _BSD_SOURCE #include <ctype.h> #define BIG_ENDIAN NO Actual results: /home/rloader/temp.c:3:1: warning: "BIG_ENDIAN" redefined In file included from /usr/include/ctype.h:41, from /home/rloader/temp.c:2: /usr/include/endian.h:47:1: warning: this is the location of the previous definition Expected results: I don't think that there should be a warning; ctype.h shouldn't be defining BIG_ENDIAN even with _BSD_SOURCE - at least it doesn't on modern BSD systems as far as I can see. (Apologies if that is indeed intended).
I don't think _BSD_SOURCE has similar rigorous namespace requirements as _XOPEN*, because no standard is defining the namespace. <ctype.h> needs <endian.h> for the bit testing macros in that header. If there was a standard that required <ctype.h> must not include <endian.h>, then the solution would be obvious, play with __need_* macros in endian.h like some other headers do. But for _BSD_SOURCE, this is not that obvious something like that is really needed.
There are no namespace guarantees for anything but POSIX and x/open modes.
Compiling as C++ with _XOPEN_SOURCE and without _BSD_SOURCE also gives the warning. Is it intended to give namespace guarentees in that case? $ cat temp.cc // Compile as C++ #include <ctype.h> #define BIG_ENDIAN NO $ g++ -D_XOPEN_SOURCE=600 -c temp.cc temp.cc:3:1: warning: "BIG_ENDIAN" redefined In file included from /usr/include/ctype.h:41, from temp.cc:2: /usr/include/endian.h:47:1: warning: this is the location of the previous definition
That's because g++ (at the moment) implies _GNU_SOURCE, which has no namespace guarantees either.