[vtk-developers] possible bug in vtkErrorMacro and vtkWarningMacro
Ken Martin
ken.martin at kitware.com
Fri May 25 09:42:23 EDT 2007
It works because our convention is that the contents of those macros start
with a string, or if not a string then a <<. Consider two examples
vtk...Macro("Why do birds suddenly appear?");
expands to "): " "Why do ...." and the preprocessor concatenates the two
strings making it valid code. The second example is
vtk...Macro(<< *vtkInstance << "hmmm");
which expands out to "): " << *vtkInstance << ...
which is also valid code.
Ken
Ken Martin PhD
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971
-----Original Message-----
From: vtk-developers-bounces+ken.martin=kitware.com at vtk.org
[mailto:vtk-developers-bounces+ken.martin=kitware.com at vtk.org] On Behalf Of
Amy Squillacote
Sent: Friday, May 25, 2007 9:34 AM
To: Vtk Developers
Subject: [vtk-developers] possible bug in vtkErrorMacro and vtkWarningMacro
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
_______________________________________________
vtk-developers mailing list
vtk-developers at vtk.org
http://www.vtk.org/mailman/listinfo/vtk-developers
More information about the vtk-developers
mailing list