Topic: compensating for changes to standard libraries in newer compilers
Author: wallac1@stamps.stortek.com (Chris Wallace)
Date: Fri, 16 Jul 2004 21:14:01 +0000 (UTC) Raw View
I hope this is a good place to pose this kind of question.
At my work I have some code that compiles and runs fine using the
current servers and gcc 2.8.1(about 6 years old so far as I can tell)
On the new servers that will replace the old ones very shortly, the
code will give compilation errors with 2.8.1. After some other people
made some changes (that also happened to deal with standard libraries
causing errors) it will compile with gcc 3.3 but seg fault as soon as
it starts running.
After investigating some, it seems as though all the problems have to
do with the included library files, particularly those that deal with
output operations(iostream, stdio, etc).
For an example, I've tried searching for terms that the compiler in
2.8.1 says don't exist such as "_Ios_Fmtflags". It seems as though
that is defined in a library file called ios_base.h and I came across
some documentation where it is defined that seems to lend to support
to my theory.
quote:
00051 // The following definitions of bitmask types are enums,
not ints,
00052 // as permitted (but not required) in the standard, in
order to provide
00053 // better type safety in iostream calls. A side effect
is that
00054 // expressions involving them are no longer compile-time
constants.
end quote
In my code, the following exists, which *I think* directly ties in
with the above statments.
(this code causes an error with 2.8.1 on the new server)
// Adjust fields for stream
_Ios_Fmtflags ioOptions = ios::right | // right justified
ios::uppercase | // uppercase characters
ios::showpoint | // explicit '+'
ios::fixed ; // floating point
numbers
Anyone know a way to deal with these sort of changes in the standard
library files? For the above I am completely clueless as to what to
do since I am not a c++ guru like the person who originally wrote this
stuff(and of course no longer works here).
Thanks in advance.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: kuyper@wizard.net (James Kuyper)
Date: Sun, 18 Jul 2004 04:03:44 +0000 (UTC) Raw View
wallac1@stamps.stortek.com (Chris Wallace) wrote in message news:<dfeb6b26.0407161240.247a98aa@posting.google.com>...
..
> with the above statments.
> (this code causes an error with 2.8.1 on the new server)
>
> // Adjust fields for stream
> _Ios_Fmtflags ioOptions = ios::right | // right justified
> ios::uppercase | // uppercase characters
> ios::showpoint | // explicit '+'
> ios::fixed ; // floating point
> numbers
>
> Anyone know a way to deal with these sort of changes in the standard
> library files? For the above I am completely clueless as to what to
> do since I am not a c++ guru like the person who originally wrote this
> stuff(and of course no longer works here).
The best solution to this kind of problem is to make sure your code
only relies upon aspects and features of the standard library headers
that are required to be there by the C++ standard. _IosFmtflags is not
one of those features; it was specific to a particular implementation
of C++, and liable to disappear without advance notice (as you have
found out).\
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]