[vtkusers] #Defines for Big or Little Endian

David Gobbi dgobbi at atamai.com
Fri Sep 1 14:41:44 EDT 2006


Mike Jackson wrote:
> On 9/1/06 2:22 PM, "Sean McBride" <sean at rogue-research.com> wrote:
>
>   
>> On 2006-09-01 12:03, Mike Jackson said:
>>
>>     
>>> As a follow up to my own post I think that in the vtkConfigure.h on OS X I
>>> think that there needs to be something like:
>>>
>>> /* Byte order.  */
>>> #if defined(__i386__) && defined(__GNUC__)
>>>    #undef VTK_WORDS_BIGENDIAN
>>> #elif defined(__ppc__) && defined(__GNUC__)
>>>    #define VTK_WORDS_BIGENDIAN
>>> #else
>>> #error Do not know the endianess of this architecture
>>> #endif
>>>
>>> At the top. This is pretty much what Apple uses in there own files. Testing
>>> is required.. Maybe put this into the next version of VTK to help out those
>>> of us trying to compile universal binaries?
>>>       
>> Well, this is all related to bug 3059. :)  Which I encourage you to
>> read.  <http://www.vtk.org/Bug/bug.php?op=show&bugid=3059>
>>
>> I would dearly like for vtk to stop checking the endianess of the
>> machine that's doing the building.  But in order for that to happen, we
>> need a way to know the endianess of the target.  All compilers on Mac OS
>> set up the  __LITTLE_ENDIAN__ and __BIG_ENDIAN__ #defines, but other
>> compilers on other platforms don't.  So, like you say, we could hack it
>> to #undef and redefine VTK_WORDS_BIGENDIAN on Mac OS.
>>
>> I'm willing to do it and test it, but I don't know enough about CMAKE
>> and how vtkConfigure.h is generated to get any farther.
>>
>> If anyone can help, please update bug 3059. :)
>>     
>
> Well, we can hack it now by changing the vtkConfigure.h.in which is at the
> top level of the vtk source distribution. We could put some sort of IF
> (APPLE) thing around the part that I describe above.
>
> Might work... Just depends when and how that vtkConfigure.h.in is used
> during the configuration process and build process.
>
> We could start special casing the Cmake files for VTK to get rid of the
> tryCompile for Apple machines and go with the __LITTLE_ENDIAN__ and
> __BIG_ENDIAN__ #defines instead. This seems a bit of a kludge to me though..
>   

For the purpose of testing, you don't need to worry about the "IF 
(APPLE)".  If it works
on the Mac,  you can always ask someone else to change the 
CMakeLists.txt files to add
that part before it gets committed to VTK cvs.

If you change VTK_WORDS_BIGENDIAN in vtkConfigure.h.in then you 
shouldn't have
to worry about changing any CMake files at all.

 - David








More information about the vtkusers mailing list