Bug 161296 - Extraneous #define from ctype.h
Extraneous #define from ctype.h
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2005-06-21 23:35 EDT by Ralph Loader
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-06-22 11:40:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Ralph Loader 2005-06-21 23:35:59 EDT
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):


Steps to Reproduce:

Compile the following:

#define _BSD_SOURCE
#include <ctype.h>

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).
Comment 1 Jakub Jelinek 2005-06-22 04:24:43 EDT
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.
Comment 2 Ulrich Drepper 2005-06-22 11:40:42 EDT
There are no namespace guarantees for anything but POSIX and x/open modes.
Comment 3 Ralph Loader 2005-06-22 17:10:26 EDT
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>

$ 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
Comment 4 Jakub Jelinek 2005-06-22 17:14:00 EDT
That's because g++ (at the moment) implies _GNU_SOURCE, which has no namespace
guarantees either.

Note You need to log in before you can comment on or make changes to this bug.