[vtk-developers] VTK_LEGACY =>invalid redeclaration of nested class and 2952d8f7bce83e318a233048606b14997b4991a1

Eric Chamberland Eric.Chamberland at giref.ulaval.ca
Mon Jan 14 11:53:29 EST 2013


Hi Brad,

On 01/14/2013 11:45 AM, Brad King wrote:
> On 01/14/2013 10:17 AM, Eric Chamberland wrote:
>> Now I have this warning from Intel compiler:
>> |
>> icpc -o ...
>>
>>    /opt/VTK/include/vtk-5.10/vtkActor.h(158): warning #1170: invalid
>> redeclaration of nested class
>>       VTK_LEGACY(virtual vtkActor *GetNextPart());
>>       ^
>
> As you discovered the macro was added here:
>
>   http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=29b6e700
>
> but it did not include the nested class declaration.  That
> was added 7 years ago here:
>
>   http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=1e4cb155
>
> with commit message:
>
>   COMP: When VTK_LEGACY_REMOVE is defined then VTK_LEGACY needs to
>   replace methods with dummy declarations to avoid stray semicolons.
>   This allows building with Borland when removing legacy code.
>   It also avoids warnings on some other compilers.
>
> The code added by that commit is still present:
>
>   #if defined(VTK_LEGACY_REMOVE)
>     // Remove legacy methods completely.  Put a bogus declaration in
>     // place to avoid stray semicolons because this is an error for some
>     // compilers.  Using a class forward declaration allows any number
>     // of repeats in any context without generating unique names.
>   # define VTK_LEGACY(method) class vtkLegacyMethodRemoved
>
> The comment explains why it works that way.
>
> What was missed, and what is not stated very clearly in the
> Intel diagnostic message, is explained by Intel here:
>
>   http://software.intel.com/en-us/articles/cdiag1170
>   "This diagnostic is issued if you redeclare a nested class
>    with different accessibilities."
>
> So we will see this when more than one method is deprecated AND
> they have different access levels (public/protected/private).
>
> Try changing the macro definition to this:
>
>   # define VTK_LEGACY(method)         VTK_LEGACY__0(method,__LINE__)
>   # define VTK_LEGACY__0(method,line) VTK_LEGACY__1(method,line)
>   # define VTK_LEGACY__1(method,line) class vtkLegacyMethodRemoved##line
>
> to add a file-wise unique number to each declaration.
>

Ok, of course I can do this.

1) Will you accept the patch if I submit it? (on which branch should I 
base/start my work on?)

2) And why the commit 2952d8f7bce83e318a233048606b14997b4991a1 which 
*removes* all the code, isn't included in the release but only present 
in the master and nightly-master?

thank you for your answer!

Eric

> -Brad
>




More information about the vtk-developers mailing list