[Insight-developers] Annoying Deprecation Warnings

Mathieu Malaterre mathieu.malaterre at gmail.com
Thu Dec 20 04:31:07 EST 2007


On Dec 19, 2007 11:20 PM, Sean McBride <sean at rogue-research.com> wrote:
> On 12/19/07 4:37 PM, Bill Lorensen said:
>
> >2) The gnu compilers give misleading warnings:
> >
> >*/.../Insight/Code/Common/itkElasticB
> >odyReciprocalSplineKernelTransform.txx:29:
> >warning: `
> >*   m_Alpha' is deprecated (declared at
> >   /.../Insight/Code/Common/itkElasticBodyReciprocalSplineKernelTransform.h
> >   :114)
> >/.../Insight/Code/Common/itkElasticB
> odyReciprocalSplineKernelTransform.txx: In
> >   member function `virtual void
> >   itk::ElasticBodyReciprocalSplineKernelTransform<TScalarType,
> >
> >m_Alpha IS NOT deprecated.
>
> I believe this be because the __attribute__((deprecated)) thingie is
> being used incorrectly.  Consider this sample:
>
> ---------------------
> #define itkLegacyMacro(method) method __attribute__((deprecated))
>
> class Foo
> {
>         void Method2 (void);
>         itkLegacyMacro( virtual void Method1(void); )
>
>         double m_Alpha;
> };
>
> void Foo::Method2 (void)
> {
>   m_Alpha = 8.0;
> }
> ---------------------
>
> This repros the warning.  The macro expansion gives:
>
>  virtual void Method1(void); __attribute__((deprecated))
>
> But it should be:
>
>  virtual void Method1(void) __attribute__((deprecated));
>
> Then there would be no warning.
>
> Apple (who I believe lobbied for this feature being added to gcc) does
> the following:
>
> #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) &&
> (__GNUC_MINOR__ >= 1)))
>     #define DEPRECATED_ATTRIBUTE __attribute__((deprecated))
> #else
>     #define DEPRECATED_ATTRIBUTE
> #endif
>
> Then declares functions like so:
>
> extern void Func (int param) DEPRECATED_ATTRIBUTE;
>

Bill,

  Having deprecation mechanism at compile is a huge time saver ! I
believe the macro were used improperly as Sean explained it. Could
someone give it a shot before removing them.

Thanks,
-Mathieu


More information about the Insight-developers mailing list