Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 60027 - compiling c++ code with gcc 2.96 targeted for i386-glibc21-linux/egcs-2.91.66 leaves __cplusplus undefined in C preprocessor (cpp)
compiling c++ code with gcc 2.96 targeted for i386-glibc21-linux/egcs-2.91.66...
Product: Red Hat Linux
Classification: Retired
Component: compat-egcs (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2002-02-19 01:03 EST by nsd20463
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-02-19 01:03:44 EST
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 nsd20463 2002-02-19 01:03:39 EST
Description of Problem:
The bug occurs when I have both compat-egcs-[c++-]6.2- installed
and the normal gcc-[c++-]2.96-98. The 2.96 gcc is the master (ie it owns /usr/bin/gcc and g++)
and so it is one that reads the /usr/lib/gcc-lib/i386-glibc21-linux/egcs-2.91.66/specs file
and invokes /usr/lib/gcc-lib/i386-glibc21-linux/egcs-2.91.66/cpp[0].

So far so good. The problem is that the 2.96 g++ does not pass the flag
-D__cplusplus=1 to the 2.91.66 cpp0. This is probably because the 2.96
cpp0 does not need it passed, since it internally defined __cplusplus when
it is passed the -lang-c++ flag from g++.

However on a redhat 6.2 system the egcs g++ passes the -D__cplusplus=1 flag
to the egcs cpp0; apparently the egcs cpp0 does not defined it internally based
off of the -lang flag.
Without the __cplusplus definition the egcs cpp0 cannot compile real-world
c++ code,since that define is used all over standard system headers.
Compilation ends in a mass of obscure errors all of which are due to __cplusplus
not having been defined.

Version-Release number of selected component (if applicable):

How Reproducible:

Steps to Reproduce:
1. Install the compat-egcs and compat-egcs-c++ rpm's from the redhat 7.2 cdrom (as well as the gcc and gcc-c++ which you probably already have) 
2. Create a simple c++ file. I'll use these 3 lines:
--------- test.cpp -------------
#ifndef __cplusplus
#  warning __cplusplus is not defined!
--------- end of test.cpp -------
Note the file needs to be named .cpp or .cxx or .cc or g++ will think it's C.
3. Compile it using the compat-egcs target
  g++ -b i386-glibc21-linux -V egcs-2.91.66 test.cpp -c

Actual Results:
test.cpp:2: warning: #warning __cplusplus is not defined!

Expected Results:
We should not see that warning, since __cplusplus should be
predefined in any c++ preprocessor.

In fact we expect no output at all.

Additional Information:
I've hacked around it by wrapping g++ in a little script that passes in 
the -D__cplusplus=1 (this was easier than understanding
and modifying 3rd party makefiles), but this is a crude hack.

BTW what I was trying to do is to use a redhat 7.2 system to build c++
executables targeted for a redhat 6.2 system.
Comment 1 Jakub Jelinek 2002-02-19 04:43:57 EST
Use i386-glibc21-linux-g++ instead of g++ then.
The gcc driver is usually quite tightly coupled with the compiler backends,
so normally you cannot use -b or -V for different major (or even minor)
version (x.y.N and x.y.M will probably work together though).
gcc driver in 2.96-RH partly supports egcs 1.1.2 backend only so that Oracle
with its hardcoded commands in scripts can link.
i386-glibc21-linux-g++ is driver for egcs 1.1.2 which should do the job.

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