[Insight-users] itkStaticConstMacro

Karthik Krishnan karthik.krishnan at kitware.com
Wed Jan 17 18:09:12 EST 2007


On 1/17/07, Karthik Krishnan <karthik.krishnan at kitware.com> wrote:
>
>
> valid for the integer type now.  This line:
> >
> >   itkStaticConstMacro( DEFAULT_REPLICA_EXCHANGE_PROBABILITY, double,
> > 0.05 )
> >
> > causes the following error:
> >
> > MY_PATH/itkPoistatsFilter.h:375: error: enumerator value for
> > `DEFAULT_REPLICA_EXCHANGE_PROBABILITY' not integer constant
>
>
> itkStaticConstMacro should be used only for "unsigned int" and "int" as
> long as ITK supports VS6.0, gcc <= 2.95. The
>
>

The point is that itkStaticConstMacro uses a "static const" on a few
> compilers and an "enum" on those where the former doesn't work.  And enum's
> are integer enumerations.
>
> So in the interest of portability please do not use itkStaticConstMacro
> for doubles.  Just do
>
>   static const double DEFAULT_REPLICA_EXCHANGE_PROBABILITY = 0;
>

Sorry,  that's what's not supposed to work on VS6.. As Luis mentioned, you
need to declare it in the header file, but define it in the implementation
file. Something like :

---
template <typename T > class foo {
public:
  static const double D;
};

template < class T > const double foo< T >::D = 0;

int main() {  return 0; }
---

will work just fine on all compilers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070117/eff2a1de/attachment.htm


More information about the Insight-users mailing list