[vtkusers] question about vtk error macro

Mark Roden mmroden at gmail.com
Sat Nov 20 19:27:44 EST 2010


I should add, this is with visual studio 2008 on a windows 7 machine, 64 bit
compiler.

On Sat, Nov 20, 2010 at 4:13 PM, Mark Roden <mmroden at gmail.com> wrote:

> Hi all,
>
> I'm having a problem with the vtk error macro, and was hoping someone could
> shed some light on the issue.
>
> The relevant lines for this problem start on line 467 of vtkGetSet.h from
> the git head:
>
>      vtkmsg << "ERROR: In " __FILE__ ", line " << __LINE__      \
>             << "\n" << self->GetClassName() << " (" << self     \
>             << "): "  x << "\n\n";                            \
>
> If x is a std::string, the above fails to compile, but the following is
> fine:
>
>      vtkmsg << "ERROR: In " __FILE__ ", line " << __LINE__      \
>             << "\n" << self->GetClassName() << " (" << self     \
>             << "): " << x << "\n\n";                            \
>
> Note the extra << right before x.
>
> I'm doing this to debug a problem in the vtkGDCMImageReader I'm having
> where images aren't being read in Java, but are read just fine in C++-- I
> think that there's a problem with string termination, but I don't know.  So,
> I want to add the filename to the debug message.
>
> The lines in gdcm are:
>
>   if( !reader.Read() )
>     {
>       //added more detail for those instances where you can't debug, like
> in java
>       std::string theFilename(filename);
>       std::string theError = "ImageReader failed on file: " + theFilename;
>       vtkErrorMacro( theError );
>       return 0;
>     }
>
> and they were:
>
>   if( !reader.Read() )
>     {
>       vtkErrorMacro( "ImageReader failed" );
>       return 0;
>     }
>
> I don't want to change vtk at all, I want to use what exists.  I could just
> modify my version right now to make my error message work (or at least
> compile)-- but how should I use the warning/error macros to get more
> information out than just a pure const char*?  I tried to use
> theError.c_str(), but that also failed.  It also failed to compile if I just
> sent filename over directly, as in vtkErrorMacro(filename);
>
> Thanks,
> Mark
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101120/d9f4fab6/attachment.htm>


More information about the vtkusers mailing list