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
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake