[mythtv] Is fixing GCC 4.0 compile issues a task for a novice?

Kyle Rose krose+mythtv at krose.org
Fri Apr 22 21:14:18 UTC 2005


Daniel Kristjansson wrote:
> Just do it, it won't be committed unless it's clean. Make sure it still
> works with gcc 2.95.3, as this is still needed for some platforms.
> I believe this basically means you can't use all the fancy C++ style
> casts,

Not true.  All the fancy (ISO) casts work great: e.g., I have been using
dynamic_cast successfully in gcc-2.95 for four years at work, and have
had zero problems.  The same was not true of gcc-2.7.x, but IMO anyone
trying to use a compiler that old can just lose.

FWIW, having done lots of 2.95->3.3 porting, the main things you'll run
into are primarily syntax:

(1) Namespace std exists and means something.  Don't just insert using
namespace std into the top of every header file.  This is *wrong* and
anyone who does this should have their C++ engineer badge shredded.

(2) hash_{set,map} aren't part of the ISO STL, so they're in namespace
__gnu_cxx instead of std.  Easy to get around:

namespace std {
	using namespace __gnu_cxx;
}

(3) You need to use typename for types declared inside template
constructs.  E.g.,

template <typename T> class bar { typedef int myint; };
.
.
.
template <typename T> f(T input)
{
   bar<T>::myint x;
}

is wrong, because the programmer is presuming the non-existence of a
specialization of bar that doesn't declare myint to be a non-type. E.g.,

template <> class bar<float> { void myint() { blah() } };

would cause a statement like "bar<T>::myint x" not to make any sense.
Thus, you need to specify "typename bar<T>::myint x" to force the
compiler to interpret bar<T>::myint as a type and fail if it isn't.

(4) basic_istream/basic_ostream don't exist in the iostream headers in
2.95, so user-overloaded operator<</>> are going to be declared differently.

There are other squirrels as well, but these are the big ones I ran into.

> but the best way to assure it still works with 2.95.3 is to
> test with that compiler in addition to testing with 4.0.

Agreed.  Generally, things that compile with 4.0 will compile with 2.95,
the latter of which is a much more permissive (read: non-compliant)
compiler, assuming you don't use any language features that weren't
implemented in the 2.95 days.

Cheers,
Kyle


More information about the mythtv-dev mailing list