[Insight-users] itkStaticConstMacro

Luis Ibanez luis.ibanez at kitware.com
Wed Jan 17 17:22:10 EST 2007



Hi Dennis,



       Ahh, the beauty of Open Source!


       Insight/Code/Common/itkMacro.h

                 lines 100-105:

#if defined(ITK_NO_INCLASS_MEMBER_INITIALIZATION) || \
     defined(ITK_NO_SIZEOF_CONSTANT_LOOKUP)
#   define itkStaticConstMacro(name,type,value) enum { name = value }
#else
#   define itkStaticConstMacro(name,type,value) static const type name = 
value
#endif


The StaticConstMacro was designed for dealing with numeric
parameters of templated classes. Such parameter can only
be "int", "unsigned int", and "enum".

However, some compilers do not support the enums, while other
do not support the initialization of static variables.

You could be ok with using the StaticConstMacro with a double
type *ONLY* in some compilers...



      So, that probably not a good approach.


You may have to just make the declaration of the static double
variable in your header file, and then initialize it in you
.cxx file.



    Regards,


       Luis


-----------------
Dennis Jen wrote:
> Hi,
>  When I upgraded from ITK 2.6.0 to 3.0.0, I got a compile error in a 
> filter I was working on.  It looks like the itkStaticConstMacro is only 
> 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
> make[2]: *** [CMakeFiles/PoistatsCLI.dir/PoistatsCLI.o] Error 1
> make[1]: *** [CMakeFiles/PoistatsCLI.dir/all] Error 2
> make: *** [all] Error 2
> 
>  Is there prescribed way to do this?
>  Thanks,
>    Dennis
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 


More information about the Insight-users mailing list