[Insight-developers] Enumeration type causes warning in XCode project

Mathieu Coursolle mcoursolle at rogue-research.com
Thu Mar 8 12:14:41 EST 2007


Hi,

I added new macros in itkMacro.h to support enum types. As explained
previously,
the itkDebugMacro causes warnings on some platform (XCode) when it
receives an 
enum type.

So I added in itkMacro.h:

- itkSetEnumMacro
- itkGetEnumMacro
- itkGetConstReferenceEnumMacro.

Those macro basically cast the enum type into a long value for output.

I currently use them in:

- itkImageIOBase.h
- itkGDCMImageIO.h
- itkDICOMSeriesFileNames.h

Those all the only one I changed yet cause they are causing the warnings
in my application.

If you agree to that change, I could parse all code and change whenever
an enum is use with the
itkDebugMacro. That fix would avoid lots of warnings when including itk
headers.

Please let me know if you want a patch for this. I would really
appreciate those warnings to
go away...

Thanks.

Mathieu

-- 
____________________________________________________________
Mathieu Coursolle                   mcoursolle at rogue-research.com
Rogue Research                      www.rogue-research.com 
Montréal, Québec, Canada


>This warning is caused because the itkSetMacro is in the header files
included
>in my project, so the warnings are in my project.
>
>Casting at the point where the warning occur would mean to cast in that
>accessor. I could implement the Set accessor for the enum type members,
>and cast
>the enum into an long type for example in that implementation. Is the
>itkSetMacro
>use for another reason than avoid rewriting the same code everytime. I
mean is
>it a problem if this macro is replace by a Set method where the enum would be
>casted?
>
>Thanks.
>
>Mathieu
>
>>Another solution would be simply to cast the use of the enum values in
>>streaming expressions to avoid the warning. (Perhaps conditionally
>>based on some preprocessor definition.)
>>
>>Casting at the point where the warning occurs would be a "less
>>intrusive" and more obviously backwards compatible change...
>>
>>Yes?
>>David
>>
>>
>>On 2/23/07, Mathieu Coursolle <mcoursolle at rogue-research.com> wrote:
>>> Hi,
>>>
>>> We are currently using ITK in a Cocoa application build with XCode.
>>> However, we get lots of warning related to enumeration types when
>>> including some ITK headers.
>>>
>>> Ex: Warning: choosing 'int' over 'long unsigned int'
>>>
>>> This is mainly caused by the itkDebugMacro, which uses the << operator
>>> of the itk::OStringStream to display some enum values. It seems like
>>> the compiler does not see the same type as the << operator for those
>>> enum types.
>>>
>>> Enum types might cause some issues asa they might not be of the same type
>>> according to the compiler (32 or 64 bits for example).
>>>
>>> A solution to fix those issues and related warning would be to set the
>>> type to use for those enums:
>>>
>>> Ex:  typedef enum { ELEMENT1, ELEMENT2, ELEMENT3} MyEnum;
>>>
>>> can be written:
>>>
>>> enum { ELEMENT1, ELEMENT2, ELEMENT3};
>>> typedef int MyEnum;
>>>
>>> This causes MyEnum to be used as an int in all cases. I changed
>>> the ones in itkImageIOBase.h, itkGDCMImageIO.h and DICOMSeriesFileName.h
>>> to get rid of all the warnings I had.
>>>
>>> I would like to know if you would agree to commit such a change to
>>> enumeration types in ITK.
>>>
>>> Thank you.
>>>
>>> Mathieu
>>>
>>> --
>>> ____________________________________________________________
>>> Mathieu Coursolle                   mcoursolle at rogue-research.com
>>> Rogue Research                      www.rogue-research.com
>>> Montréal, Québec, Canada
>>>
>>> _______________________________________________
>>> Insight-developers mailing list
>>> Insight-developers at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-developers
>>>
>>
>
>
>_______________________________________________
>Insight-developers mailing list
>Insight-developers at itk.org
>http://www.itk.org/mailman/listinfo/insight-developers
>





More information about the Insight-developers mailing list