This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Proper and portable ways using manipulator
- From: LLeweLLyn Reese <llewelly at lifesupport dot shutdown dot com>
- To: Wei Qin <wqin at EE dot Princeton dot EDU>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 07 Aug 2003 21:41:57 -0700
- Subject: Re: Proper and portable ways using manipulator
- References: <Pine.SOL.4.43.0308071808180.5638-100000@ivy.ee.princeton.edu>
Wei Qin <wqin@EE.Princeton.EDU> writes:
> Hi,
> I used some manipulators in the form of
>
> #include <iostream>
> #include <ios>
Try:
#include <iomanip>
instead. (Note: I don't have 2.96 availible to test.)
>
> int main () {
>
> std::cout << std::showbase << std::hex << 100 << std::endl;
> }
>
> This compiles fine with g++ 3.x. However, it fails on g++ 2.96
> since it cannot find ios. When I remove ios, it cannot find showbase. Then
> I change std::showbase to std::ios::showbase, but this showbase is not a
> manipulator any more. As a result the program outputs 8064 instead of
> 0x64.
> So my question is: Is there any good coding practice to make sure
> that the same code compiles for both and works as intended? Thanks.
Compile every change with both compilers.