[Insight-developers] Re: Suppressing Deprecation Warnings
    Brad King 
    brad.king at kitware.com
       
    Fri Dec 28 14:23:17 EST 2007
    
    
  
Bill Lorensen wrote:
> The problem  is the warnings occur even if the method is not used.
I've duplicated this problem as follows:
   struct A
   {
     virtual void __declspec(deprecated) f();
   };
   struct B: public A
   {
     virtual void __declspec(deprecated) f();
   };
The warning is
   tdep.cxx(8) : warning C4996: 'A::f' was declared deprecated
                 tdep.cxx(3) : see declaration of 'A::f'
The reason seems to be that overriding a virtual function that has been 
marked deprecated causes the warning.  There does not seem to be any way 
to turn off this warning except with "-w" to turn off all warnings.
This adds to my list of reasons to never make virtual functions part of 
the public interface.  The above should instead be
   class A
   {
   public:
     void __declspec(deprecated) f() { this->f_internal(); }
   protected:
     virtual void f_internal();
   };
   class B: public A
   {
   protected:
     virtual void f_internal();
   };
Unfortuntately it is way too late to change all ITK's methods.  However 
perhaps this can be done for the deprecated methods if they are not 
meant to be overridden by users.
Otherwise I guess we should build some dashboards with ITK_LEGACY_REMOVE 
and the rest with ITK_LEGACY_SILENT.  Note that this is a problem only 
for MSVC.  GCC only warns on a call to the method.
-Brad
    
    
More information about the Insight-developers
mailing list