next up previous
Next: Creating a templates file Up: Notes on using the Previous: Upcasting Bug

Typedef Bug

The g++ compiler sometimes complains it cannot find a type definition even when it has definitely been included. For example I found that it was complaining that Vector<Int> was undefined even though aips/Arrays/Vector.h was included. To solve this add the line:

   typedef Vector<Int> gpp_vector_int;
near the top of the .cc file. the type gpp_vector_int is arbitrary but this seems like a good convention (Brian's convention).

This appears to occur when a specific templated types used in the context of a general template definition. eg.

   template <class T> const Lattice<Bool> &PagedImage<T>::mask() const
will trigger this bug because requiring a typedef for Lattice<Bool>

I enclose this change and others that are specific to the gnu compiler in ifdefs's to avoid getting other compilers off side. eg.

   #ifdef __GNUG__
      typedef Vector<Int> gpp_vector_int;
   #endif
It is not necessary to do this when using the array upcasting functions (arrayCast() etc.) described in section 1.1.6.

The error messages that indicate you are being affected by this bug can be quite obscure and are listed in section 1.1.11



Ralph Marson
Wed Aug 28 17:15:27 MDT 1996