[vtkusers] #Defines for Big or Little Endian

Glen Lehmann glehmann at atamai.com
Thu Aug 31 17:23:01 EDT 2006


Hi, Mike,

Your VTK-binary-dir/vtkConfigure.h file will #define
VTK_WORDS_BIGENDIAN on a big endian machine.   Otherwise,
VTK_WORDS_BIGENDIAN is undefined on a little endian machine.

To do byte swapping, independent of the host architecture, I use
vtkByteSwap::SwapVoidRange.  Something like:

int x;

if (this->SwapBytes)
{
  vtkByteSwap::SwapVoidRange(&x, 1, 4);
}

Cheers,

Glen


On 31/08/06, Mike Jackson <imikejackson at gmail.com> wrote:
> Is there a #define some where that I can use to test if I am running
> on a big or little endian machine?
>
> Beyond that, are there already methods some where that I have not
> found that will take a value, say UIn32 and swap the bytes to whatever
> the system is? Something like:
>
> ByteSwap::swapLEToSystem( UInt32 );
>
> Thanks
>
> --
> Mike Jackson
> imikejackson _at_ gee-mail dot com
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list