[Insight-developers] Enumeration type causes warning in XCode
project
Mathieu Coursolle
mcoursolle at rogue-research.com
Wed Feb 28 18:27:23 EST 2007
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
>>
>
More information about the Insight-developers
mailing list