public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Chris BeHanna <behanna@zbzoom.net>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org
Subject: Re: preprocessor/3049: Conditional compilation using "#if A==B"broken on i386 Red Hat 7.0.
Date: Mon, 04 Jun 2001 16:06:00 -0000	[thread overview]
Message-ID: <20010604230601.19596.qmail@sourceware.cygnus.com> (raw)

The following reply was made to PR preprocessor/3049; it has been noted by GNATS.

From: Chris BeHanna <behanna@zbzoom.net>
To: Neil Booth <neil@daikokuya.demon.co.uk>
Cc: <gcc-gnats@gcc.gnu.org>
Subject: Re: preprocessor/3049: Conditional compilation using "#if A==B"
 broken on i386 Red Hat 7.0.
Date: Mon, 4 Jun 2001 19:02:32 -0400 (EDT)

 On Mon, 4 Jun 2001, Neil Booth wrote:
 
 > behanna@zbzoom.net wrote:-
 >
 > > #if BYTE_ORDER == BIG_ENDIAN
 > > // stuff
 > > #endif
 > > #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
 > > // stuff
 > > #endif
 >
 > > results in both sections of code getting processed on Red Hat 7.0 if
 > > _XOPEN_SOURCE is defined.  The problem does not occur if _XOPEN_SOURCE
 > > is not defined.  The attached program reproduces this problem.
 >
 > That raises the obvious question: can you tell me what are the values
 > of BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER and PDP_ENDIAN when you
 > define _XOPEN_SOURCE?  (e.g. put them through a printf).
 >
 > I'd be extremely suprised if this is a CPP bug, but if it is we need
 > to fix it quickly.
 
     The test program won't even compile with the following lines added
 after the last #endif and -D_XOPEN_SOURCE on the compile line:
 
   cout << "BIG_ENDIAN    = " << BIG_ENDIAN << endl;
   cout << "LITTLE_ENDIAN = " << LITTLE_ENDIAN << endl;
   cout << "PDP_ENDIAN    = " << PDP_ENDIAN << endl;
   cout << "BYTE_ORDER    = " << BYTE_ORDER << endl;
 
 I get the following errors:
 
 /home/cbehanna/t.cpp: In function `int main (int, char **)':
 /home/cbehanna/t.cpp:15: `BIG_ENDIAN' undeclared (first use this
 function)
 /home/cbehanna/t.cpp:15: (Each undeclared identifier is reported only
 once for each function it appears in.)
 /home/cbehanna/t.cpp:16: `LITTLE_ENDIAN' undeclared (first use this
 function)
 /home/cbehanna/t.cpp:17: `PDP_ENDIAN' undeclared (first use this
 function)
 /home/cbehanna/t.cpp:18: `BYTE_ORDER' undeclared (first use this
 function)
 
 It of course compiles just fine if -D_XOPEN_SOURCE is omitted.
 
     This explains why both sections of code are executed:  they
 effectively evaluate to #if 0 == 0.
 
     In endian.h, we find the following:
 
     #ifdef  __USE_BSD
     # define LITTLE_ENDIAN  __LITTLE_ENDIAN
     # define BIG_ENDIAN __BIG_ENDIAN
     # define PDP_ENDIAN __PDP_ENDIAN
     # define BYTE_ORDER __BYTE_ORDER
     #endif
 
 Of course, __USE_BSD is not defined when _XOPEN_SOURCE is defined.
 This breaks a lot of things, not just endian.h.  Looks like Red Hat
 screwed the pooch.
 
     I suppose it would make sense at this point to report this to Red
 Hat and close out the PR.  Sorry about that.
 
 -- 
 Chris BeHanna
 Software Engineer                   (Remove "bogus" before responding.)
 behanna@bogus.zbzoom.net
 I was raised by a pack of wild corn dogs.
 


             reply	other threads:[~2001-06-04 16:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-04 16:06 Chris BeHanna [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-06-04 15:36 preprocessor/3049: Conditional compilation using "#if A==B" broken " Neil Booth
2001-06-04 14:16 behanna

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010604230601.19596.qmail@sourceware.cygnus.com \
    --to=behanna@zbzoom.net \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).