g++ mini-FAQ


g++ requires explicit use of typename if return type is a dependent template object:

template <typename T> typename DListT<T>::iterator DListT<T>::begin() {

   // implementation
}
 

This was not required by earlier versions of Visual C++, but is accepted by the current release.

g++ has trouble with some explicit typecasts:

g++ doesn't like expressions of the form:    ... = unsigned int(foo);

g++ did like a C-style typecast:    ... = (unsigned int) (foo);

 

Both are accepted by the current release of Visual C++.

g++ objects to declaring a non-template friend function within a template declaration:

g++ doesn't like:    friend operator<<(ostream& Out, const foo<T>& Foo);
g++ did like:          friend operator<< <>(ostream& Out, const foo<T>& Foo);


Both are accepted by the current release of Visual C++.

g++ enforces the ISO Standard for loop scope rule:

 g++ doesn't like:

for (int Pos = 0; Pos < Limit; Pos++) {
   ...
}
if ( Pos == Limit )... // ISO says: this is an illegal reference

g++ does like:

int Pos;
for (Pos = 0; Pos < Limit; Pos++) {
...
}
if ( Pos == Limit )...

 

g++ whines about having no newline at end of input file:

g++ doesn't like source files that don't have a return at the end of the last line... just a warning and no big deal.