[CMake] [Insight-developers] 64 bit build detection
Michael Wild
themiwi at gmail.com
Thu Jun 18 01:44:53 EDT 2009
On 18. Jun, 2009, at 0:49, Sean McBride wrote:
> On 6/14/09 10:05 PM, Michael Wild said:
>
>> On Mac OS X one shouldn't do this kind of detection during configure
>> step, because as has been mentioned a single file can be compiled
>> multiple times for different architectures during one single compiler
>> invocation. The size of void* and even endianness can change. It is
>> preferable to have a central config.h.in (or similar) containing
>> something like this:
>>
>> #if defined(__APPLE__)
>> # if defined(__i386__)
>> # undef HAVE_64_BIT
>> # undef HAVE_BIG_ENDIAN
>> # elif defined(__ppc__)
>> # undef HAVE_64_BIT
>> # define HAVE_BIG_ENDIAN
>> # elif defined(__x86_64__)
>> # define HAVE_64_BIT
>> # undef HAVE_BIG_ENDIAN
>> # elif defined(__ppc64__)
>> # define HAVE_64_BIT
>> # define HAVE_BIG_ENDIAN
>> # else
>> // oops
>> # error "Unknown architecture!"
>> # endif
>> #else
>> # cmakedefine HAVE_64_BIT
>> # cmakedefine HAVE_BIG_ENDIAN
>> #endif
>
> I agree with Hendrik that such things are better done with types like
> uin32_t, etc. The quoted stuff above will fail with OS X running on
> ARM
> (ie iPhone).
>
Above code for sure is far from ideal or perfect. But sometimes one
inherits a code which relies on such details, so here is one
relatively simple way to deal with it. And I somehow doubt that there
are many codes running both on x86/ppc and iPhone... Besides, uint32_t
and related are not present on Windows, so using them is going to
break the code there.
Michael
More information about the CMake
mailing list