This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]