Description of Problem: The bug occurs when I have both compat-egcs-[c++-]6.2-1.1.2.16 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): gcc-2.96-98 gcc-c++-2.96-98 compat-egcs-6.2-1.1.2.16 compat-egcs-c++-6.2-1.1.2.16 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! #endif --------- 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 3. 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.
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.