[Insight-users] NumericTraits level 3 warnings on VS 2008

Niels Dekker niels-xtk at xs4all.nl
Wed Dec 3 10:13:59 EST 2008


>> I think it would be better to just locally disable warning C4310,
>> in itkNumericTraits.h:
>>
>> #ifdef _MSC_VER
>> #pragma warning (push)
>> #pragma warning (disable: 4310) // cast truncates constant value
>> #endif
>>
>> static char min() { return char(255) < 0 ? -128 : 0; }
>> static char max() { return char(255) < 0 ? 127 : 255; }
>>
>> #ifdef _MSC_VER
>> #pragma warning (pop)
>> #endif

Denis Shamonin wrote:
> Niels, your solution looks fine for me.

Okay, Denis, I reported your request at 0008213: "itkNumericTraits.h 
warning C4310 (MSVC): cast truncates constant value"
http://public.kitware.com/Bug/view.php?id=8213

As my Experimental test went well, I just committed:
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/Common/itkNumericTraits.h?root=Insight


> I am not sure if you have to use:
> #ifdef _MSC_VER
> #if _MSC_VER > 1400
> // For MS Visual Studio higher than Visual C++ 2005
> ...

The "#ifdef _MSC_VER" is important, because the warning is Microsoft 
compiler-specific.  But the warning isn't specific to a certain version 
of MSVC, so I didn't put a version check in there.  (FWIW, the warning 
doesn't appear on MSVC 6.0, but disabling the warning doesn't harm on 
MSVC 6.0 either.)


HTH, Niels



More information about the Insight-users mailing list