[vtkusers] VTK Compile Error with Clang.

Michael Jackson mike.jackson at bluequartz.net
Tue Jul 27 11:47:07 EDT 2010


I have created a reproducible test case of this with a possible  
correction that at least works on GCC.

#include <iostream>

#define vtkIndent int

//  
-----------------------------------------------------------------------------
//
//  
-----------------------------------------------------------------------------
class  vtkArray
{
public:
   void PrintSelf(std::ostream &os, vtkIndent indent) {
     std::cout << "vtkArray PrintSelf" << std::endl;
   }

};

//  
-----------------------------------------------------------------------------
//
//  
-----------------------------------------------------------------------------
template<class ThisT, class BaseT>
class vtkTypeTemplate :
   public BaseT
{
public:
   typedef BaseT Superclass;

};

//  
-----------------------------------------------------------------------------
//
//  
-----------------------------------------------------------------------------
template<typename T>
class vtkTypedArray : public vtkTypeTemplate<vtkTypedArray<T>, vtkArray>
{
public:
   typedef  vtkTypeTemplate<vtkTypedArray<T>, vtkArray> Superclass;
   void PrintSelf(std::ostream &os, vtkIndent indent)
   {
     Superclass::PrintSelf(os, indent);
   }

};

//  
-----------------------------------------------------------------------------
//
//  
-----------------------------------------------------------------------------
int main (int argc, char const *argv[])
{
   vtkTypedArray<int> array;
   array.PrintSelf(std::cout, 1);
   return 0;
}


Note that I added a "typedef  vtkTypeTemplate<vtkTypedArray<T>,  
vtkArray> Superclass;" to the vtkTypedArray class declaration. After  
that is added one can edit the vtkTypedArray definition for the  
PrintSelf() method to be the following:

   void PrintSelf(std::ostream &os, vtkIndent indent)
   {
     Superclass::PrintSelf(os, indent);
   }

This code compiles under both GCC and clang. This same subject has  
also been raised on the clang mailing list in order to better  
understand the nature of the compiler error.

Comments.
___________________________________________________________
Mike Jackson                      www.bluequartz.net
Principal Software Engineer       mike.jackson at bluequartz.net
BlueQuartz Software               Dayton, Ohio

On Jul 26, 2010, at 4:26 PM, Michael Jackson wrote:

> There is an experimental VTK build using the Clang compiler for OS X  
> at <http://www.cdash.org/CDash/viewBuildError.php?buildid=675261>.  
> There is a compiler error early on in the vtkTypedArray code:
>
> In file included from /.../VTK/Common/vtkArray.cxx:23:
> In file included from /.../VTK/Common/vtkDenseArray.h:48:
> In file included from /.../VTK/Common/vtkTypedArray.h:113:
> /.../VTK/Common/vtkTypedArray.txx:28:27: error: no member named  
> 'Superclass' in 'vtkTypedArray<T>'
> this->vtkTypedArray<T>::Superclass::PrintSelf(os, indent);
>      ~~~~~~~~~~~~~~~~~~^
> In file included from /.../VTK/Common/vtkArray.cxx:23: In file  
> included from /.../VTK/Common/vtkDenseArray.h:203:
> shouldn't that be:
> vtkTypedArray<T>::Superclass::PrintSelf(os, indent); because we are  
> really wanting to call the superclass implementation? putting the  
> "this->" does imply there is an actual member variable named  
> "vtkTypedArray<T>" declared in that class?
> or I could be absolutely flat wrong and there is a bug in Clang.  
> Either way, the issue might be able to be fixed. Just trying to get  
> VTK ready for the upcoming Xcode 4 where llvm 2.0 may be the primary  
> compiler.
> Thanks for any comments.
> ___________________________________________________________
> Mike Jackson                      www.bluequartz.net
> Principal Software Engineer       mike.jackson at bluequartz.net
> BlueQuartz Software               Dayton, Ohio
>
>




More information about the vtkusers mailing list