MantisBT - ITK
View Issue Details
0004618ITKpublic2007-03-16 11:242010-10-21 12:31
Mathieu Coursolle 
Luis Ibanez 
lowminoralways
closedfixed 
 
 
0004618: itkDebugMacro causes warning in XCode with enum types.
When including itk headers in a XCode project, the itkSetMacro, itkGetMacro, itkGetConstMacro and itkGetConstReferenceMacro produce a warning when the input type is an enum:

/include/InsightToolkit/IO/itkImageIOBase.h: In member function 'virtual void itk::ImageIOBase::SetPixelType(itk::ImageIOBase::IOPixelType)':
/include/InsightToolkit/IO/itkImageIOBase.h:136: warning: passing 'itk::ImageIOBase::IOPixelType' chooses 'int' over 'long unsigned int'
/include/InsightToolkit/IO/itkImageIOBase.h:136: warning: in call to 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]'

A patch is provide which solves the problem for the IO classes. New macro were added to handle enum types: itkSetEnumMacro, etc. The enum type is there casted into a long value to force the type.

Another proposed solution would be to force the enum type at declaration:

Replace typedef enum{TYPE1, TYPE2} MyEnum;

with

enum { TYPE1, TYPE2}
typedef long MyEnum;

This forces the enum type. Otherwise, the enum type might be considered as a different type according to the platform it is used on. This is mainly true for 64 bits platforms.
No tags attached.
txt patchfileEnums.txt (4,585) 1969-12-31 19:00
https://public.kitware.com/Bug/file/944/patchfileEnums.txt
txt patch.txt (1,090) 2009-03-02 12:36
https://public.kitware.com/Bug/file/2087/patch.txt
Issue History
2009-03-02 12:35Mathieu CoursolleNote Added: 0015493
2009-03-02 12:35Mathieu CoursolleStatusclosed => feedback
2009-03-02 12:35Mathieu CoursolleResolutionfixed => reopened
2009-03-02 12:36Mathieu CoursolleFile Added: patch.txt
2009-03-02 12:37Mathieu CoursolleNote Added: 0015494
2009-06-04 10:14Sean McBrideNote Added: 0016635
2009-06-05 12:06Sean McBrideNote Added: 0016646
2009-06-05 12:06Sean McBrideStatusfeedback => resolved
2009-06-05 12:06Sean McBrideResolutionreopened => fixed
2010-10-21 12:31Gabe HartStatusresolved => closed

Notes
(0006828)
Luis Ibanez   
2007-03-18 11:11   
The patch was modified to have only a Get macro that generates a const method.

http://www.itk.org/cgi-bin/viewcvs.cgi/Code/Common/itkMacro.h?root=Insight&sortby=date&r2=1.70&r1=1.69 [^]
(0015493)
Mathieu Coursolle   
2009-03-02 12:35   
CVS revision 1.19 of itkConnectedThresholdImageFilter reintroduced the issue.

Building with xCode 3.1.2 on Mac OS 10.5.6 produces the warning for the Connectiviy ivar when ITK_USE_REVIEW is turned on.

The itkSetEnumMacro and itkGetEnumMacro should be used instead of itkSetMacro and itkGetMacro for enum types.

A patch will be provided.
(0015494)
Mathieu Coursolle   
2009-03-02 12:37   
patch.txt was uploaded (See 0015493 note).
(0016635)
Sean McBride   
2009-06-04 10:14   
Luis, any objections to me committing this? It seems quite harmless.
(0016646)
Sean McBride   
2009-06-05 12:06   
/cvsroot/Insight/Insight/Code/BasicFilters/itkConnectedThresholdImageFilter.h,v <-- itkConnectedThresholdImageFilter.h
new revision: 1.22; previous revision: 1.21