[Insight-developers] Annoying Deprecation Warnings

Sean McBride sean at rogue-research.com
Wed Dec 19 17:20:48 EST 2007


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;

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada



More information about the Insight-developers mailing list