[vtkusers] #Defines for Big or Little Endian

Mike Jackson mike.jackson at imts.us
Fri Sep 1 11:58:35 EDT 2006


On 9/1/06 11:19 AM, "David Gobbi" <dgobbi at atamai.com> wrote:

> Mike Jackson wrote:
>> On 9/1/06 10:56 AM, "Sean McBride" <sean at rogue-research.com> wrote:
>> 
>>   
>>> I believe vtkByteSwap is the only class that does anything like this.
>>> You might want to search all the vtk code for "VTK_WORDS_BIGENDIAN" to
>>> learn a little more about how vtk does swapping.
>>> 
>>> Personally, I find Apple's APIs are much better named, but I believe
>>> vtkByteSwap::Swap4BE(), for example, swaps a 4 byte value from host to big.
>>>     
>> 
>> No, actually vtkByteSwap::Swap4BE() does the swap period. It does not pay
>> attention to if it actually _needs_ to be done. It just does it.
>>   
> 
> I don't understand what you're saying here.  Swap4BE will always do a
> swap on a little-endian machine, and will never do a swap on a
> big-endian machine.  So it only does the swap if the swap needs to be done.
> 
> Likewise, Swap4LE will only do the swap on a big-endian machine.
> 
> Are you sure that you are using these methods correctly?
> 
>  - David  
> 

Nope.. Not that I wasn't using them correctly, I wasn't completely
understanding what they did (Maybe it is those really verbose method names
;-) )
 The trouble I think I would have is if in my own code I tested for
VTK_WORDS_BIGENDIAN from vtkConfigure.h. That would mess up my code half the
time when compiling for both PPC and Intel. The vtk libs that are compiled
are already correct in that they will do the right thing on the right
platform. 
   In my own code however when testing for Endian-ness I should be using the
gnu defines __LITTLE_ENDIAN__ and __BIG_ENDIAN__ instead. I believe this
will get around the universal binary issue.

Now this ONLY works in universal binary because at the moment I am compiling
each platform on its own machine, ie I compile ppc vtk on a PPC machine and
intel vtk on an intel machine. Then Lipo them together.

So in the end I had a little bit of confusion over the vtkByteSwap functions
and there are still subtle issues with cross compiling source on OS X using
vtk headers.

Thanks for the clarifications.
-- 
 ______________________________________________________________________
/ Mike Jackson   Senior Research Engineer
|  CTMD Group - Materials and Manufacturing Directorate - AFRL - WPAFB
|  Innovative Management & Technology Services
|  2900 Presidential Dr, Suite 170         Fairborn Ohio     45324






More information about the vtkusers mailing list