[Insight-developers] Suggestions with "simple" expression

Bill Lorensen bill.lorensen at gmail.com
Sat May 18 15:11:14 EDT 2013


Try int's. See:
http://www.stroustrup.com/C++11FAQ.html#narrowing

const char  buffer[3] = { 255, 255, 254};



On Sat, May 18, 2013 at 1:09 PM, Bradley Lowekamp <blowekamp at mail.nih.gov>wrote:

> Hello,
>
> I pushed some code yesterday and it's causing a couple problem. It seems
> simple enough. Whats the best way to express this?
>
>    // MAGIC_NUMBER = 16777214 ( little endian )
>    const char  buffer[3] = { 0xFF, 0xFF, 0xFE};
>
>
> ERROR:
> /Users/builder/external/ITK/Modules/IO/Mesh/src/itkFreeSurferBinaryMeshIO.cxx:311:31:
> error: constant expression evaluates to 255 which cannot be narrowed to
> type 'char' [-Wc++11-narrowing]
>    const char  buffer[3] = { 0xFF, 0xFF, 0xFE};
>                              ^~~~
> /Users/builder/external/ITK/Modules/IO/Mesh/src/itkFreeSurferBinaryMeshIO.cxx:311:31:
> note: override this message by inserting an explicit cast
>    const char  buffer[3] = { 0xFF, 0xFF, 0xFE};
>                              ^~~~
>                              static_cast<char>( )
>
>
> WARNING:
>
> var/lib/jenkins/jobs/ITK-v4-Testing-32-chroot/workspace/MyTests/ITK/Modules/IO/Mesh/src/itkFreeSurferBinaryMeshIO.cxx:
> In member function 'virtual void
> itk::FreeSurferBinaryMeshIO::WriteMeshInformation()':
> /var/lib/jenkins/jobs/ITK-v4-Testing-32-chroot/workspace/MyTests/ITK/Modules/IO/Mesh/src/itkFreeSurferBinaryMeshIO.cxx:311:47:
> warning: narrowing conversion of '255' from 'int' to 'const char' inside {
> } is ill-formed in C++11 [-Wnarrowing]
>
>
> Thanks for your suggestion.
>
> Brad
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>



-- 
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20130518/0af5d77e/attachment.htm>


More information about the Insight-developers mailing list