This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Proper and portable ways using manipulator
- From: Wei Qin <wqin at EE dot Princeton dot EDU>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 7 Aug 2003 18:21:03 -0400 (EDT)
- Subject: Proper and portable ways using manipulator
Hi,
I used some manipulators in the form of
#include <iostream>
#include <ios>
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.
Wei