[vtk-developers] Warning in vtkExtractSelectedIds

David Gobbi david.gobbi at gmail.com
Fri Dec 30 10:26:20 EST 2011


Curly braces will not cause shadow warnings to go away.  The only way
to avoid shadow warnings is to use a new name, or to add a new
function.

The ExtractCells and ExtractPoints methods could be re-written
so that they use nested calls to templated functions instead of
using that macro, i.e. at one function level it would use
vtkExtentedTemplateMacro and at the other it would use
vtkTemplateMacro.

There is another reason for doing this: efficiency.  Right now,
vtkESI_ExtendedTemplateMacro is used within the inner loop of
the algorithm:

while ()
{
  macro with huge nested switch statement
}

It would be two orders of magnitude more efficient to do things this way:

vtkExtendedTemplateMacro -> calls templated func1
func1: vtkTemplateMacro -> calls templated func2
func2: while () { ... }

 - David


On Fri, Dec 30, 2011 at 8:12 AM, David Cole <david.cole at kitware.com> wrote:
> Does the warning go away if you enclose the entire definition in curly
> braces? Like this:
>
> #define vtkESI_ExtendedTemplateMacro(t1, t2, call)\
>   {\
>   switch (t1)\
>     {\
> ...
>   }\
>   }
>
>
> On Fri, Dec 30, 2011 at 9:59 AM, David Doria <daviddoria at gmail.com> wrote:
>>
>> When I compile with -Wshadow I get warnings in
>> vtkExtractSelectedIds.cxx at line 504:
>>
>> Graphics/vtkExtractSelectedIds.cxx:504:7: error: declaration of
>> ‘VTK_TT’ shadows a previous local [-Werror=shadow]
>>
>> This line calls the vtkESI_ExtendedTemplateMacro (defined at line
>> 222). This has nested calls to vtkTemplateMacro (line 662 in
>> vtkSetGet.h). The macro expands to:
>>
>> switch (idArrayType)
>> { case 11:
>>  { typedef double VTK_TT; typedef VTK_TT VTK_TT1;
>>   switch (labelArrayType) {
>>       case 11: { typedef double VTK_TT;
>>
>> in which you can see VTK_TT is typedef'ed twice.
>>
>> Utkarsh - I believe you wrote these lines - any suggestions how to fix
>> this?
>>
>> David



More information about the vtk-developers mailing list