By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,148 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,148 IT Pros & Developers. It's quick & easy.

std::uppercase & gcc

P: n/a
Hi everybody,

I have a problem with the following code:

#include <iostream>

int main(void) {
std::cout << std::hex << std::uppercase << 31 <<std::endl;

return 0;
}

It compiles fine with msvc 6.0 (windows) and gcc 3.3 (linux). If I
compile it under linux with some older gcc (2.95.3), it always complains
about the "uppercase" modifier, like:

test.cpp: In function `int main()':
test.cpp:4: `::uppercase' undeclared (first use here)

Question is: What can I do to make it run on all platforms: windows (vc
6.0) and linux/solaris (gcc 2.95, 3.3)?

Thanks for your help,
Paul

Jul 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Paul Schwann" <pa**********@philips.com> wrote in message
news:3f*********************@businessnews.de.uu.ne t...
#include <iostream>

int main(void) {
std::cout << std::hex << std::uppercase << 31 <<std::endl;

return 0;
}

Make sure that your iostream header is including the ios_base. Do a grep:
grep uppercase *ios*.h and make sure it's contained within it. Some older
implementations require a separate iosbase. If you are lazy, you can try
including ios which is under c++/bits/ios_base.h or simply <ios>.

Also, do not use void as the argument to main, either use main() or main(int
argc, char* argv[]) as the standard commands! =)
Jul 19 '05 #2

P: n/a
Thank you very much Greg, for your fast answer!

I'm afraid, it does not help or I do not understand exactly what you
mean. Doing a grep over my include paths only has one result: there is
an "uppercase" definition in a file "streambuf.h". Including it in my
little app does not help.
The files "ios" or "ios_base.h" you mentioned do not exist. Do I really
have to upgrade all the linux machines to gcc 3.3 just to run that
little stupid application?!

Regards
Paul

Jul 19 '05 #3

P: n/a
"Paul Schwann" <pa**********@philips.com> wrote in message
news:3f*********************@businessnews.de.uu.ne t...
Thank you very much Greg, for your fast answer!

I'm afraid, it does not help or I do not understand exactly what you
mean. Doing a grep over my include paths only has one result: there is
an "uppercase" definition in a file "streambuf.h". Including it in my
little app does not help.
The files "ios" or "ios_base.h" you mentioned do not exist. Do I really
have to upgrade all the linux machines to gcc 3.3 just to run that
little stupid application?!


Sadly, I think you may. I don't remember ever having that problem with gcc
2.9x.x, though I also don't remember having to use std::uppercase.

For some reason your implementation of GCC's C++ library is not holding true
to the C++ standard. You should have a standard include of <ios>. Telling me
you don't have it makes me wonder if you have some missing files.

When you grep'd, did the result show the definition of uppercase as 0x4000?
--

Regards,
Greg P.

Golden Rule of Open Source Programming:
"Don't whine about something unless you plan to implement it yourself"
Jul 19 '05 #4

P: n/a
In streambuf.h, a class "ios" is defined having an enumeration with "...
uppercase=_IO_UPPERCASE, ..." where _IO_UPPERCASE comes from libio.h and
has the value 01000 (octal 1000?).

If I modify my little program like this:

#include <iostream>

int main(void) {
std::cout.setf(ios::uppercase);
std::cout << std::hex << 31 <<std::endl;

return 0;
}

it compiles and runs just fine on linux with gcc 2.95.3. Of course, this
does not compile with gcc 3.3 nor vc6. Probably, I have to create 2
different versions of that application. Unbeliveable.

Thanks anyway Greg!

Regards, Paul

Jul 19 '05 #5

P: n/a
"Paul Schwann" <pa**********@philips.com> wrote in message
news:3f*********************@businessnews.de.uu.ne t...
#include <iostream>

int main(void) {
std::cout.setf(ios::uppercase);
std::cout << std::hex << 31 <<std::endl;

return 0;
}

it compiles and runs just fine on linux with gcc 2.95.3.
Of course, this does not compile with gcc 3.3 nor vc6.


Possibly it would help to change that "ios::uppercase"
to "std::ios::uppercase", but I don't have gcc 3.3 handy,
so I can't check that.

I must say you're not the only one with "silly" stream
issues when it comes to gcc differences. I remember
having similar problems with stream modifiers. In the
craziest of cases one gcc version recognized a modifier
(ios::showpoint was it?) and behaved correctly, whereas
the other... dumped the value of the modifier into the
stream as if it was a number, unbelievable. Perhaps the
more experienced people here could help -- I'm only
aware there's a bit of a mess when it comes to streams
and gcc.

HTH,
- J.
Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.