[vtk-developers] possible bug in vtkErrorMacro and vtkWarningMacro

Amy Squillacote amy.squillacote at kitware.com
Fri May 25 09:34:16 EDT 2007


Hi All,

Earlier today, someone pointed out to me a possible bug in vtkErrorMacro 
and vtkWarningMacro; see below.

#define vtkErrorMacro(x)                        \
   vtkErrorWithObjectMacro(this,x)

//
// This macro is used to print out errors
// vtkErrorWithObjectMacro(self, << "Error message" << variable);
//
#define vtkErrorWithObjectMacro(self, x)                        \
   {                                                            \
   if (vtkObject::GetGlobalWarningDisplay())                    \
     {                                                          \
     vtkOStreamWrapper::EndlType endl;                          \
     vtkOStreamWrapper::UseEndl(endl);                          \
     vtkOStrStreamWrapper vtkmsg;                               \
     vtkmsg << "ERROR: In " __FILE__ ", line " << __LINE__      \
            << "\n" << self->GetClassName() << " (" << self     \
            << "): " x << "\n\n";                               \    
<----- offending line
    ...
   }

Shouldn't the line indicated above actually be the following (adding 
"<<" before "x")?
<< "): " << x << "\n\n";                               \

Similar code can also be found in the vtkWarningMacro. It looks like a 
bug to me, but at the same time it's hard to believe that it's actually 
a bug because of how much those two macros are successfully used. 
According to cvs annotate, that line has been that way since December 
2002. Do you think it's a bug? If not, why not?

- Amy

-- 
Amy Squillacote
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
Phone: (518) 371-3971 x106




More information about the vtk-developers mailing list