[pisa-src] Re: r1559 - in trunk: libpisa/global.h libpisa/nat.c libpisa/nat.h pisacd/cdtun.c pisasd/sdtun.c

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Sat, 07 Nov 2009 14:07:51 +0100

On Sat, Nov 07, 2009 at 01:13:53PM +0100, Tobias Heer wrote:
> 
> Log:
> OS X Compatibility I
> 
> This is a first attempt to improve PISA's portability.
> 
> --- trunk/libpisa/global.h    Fri Nov  6 18:06:48 2009        (r1558)
> +++ trunk/libpisa/global.h    Sat Nov  7 13:13:53 2009        (r1559)
> @@ -114,6 +114,19 @@
>  #define FALSE 0
>  #endif

Unrelated remark: What are these weird definitions for?

> +/**
> + * __BYTE_ORDER is not available on _APPLE_

typo :)

> + */
> +#ifdef __APPLE__
> +  #ifndef __BYTE_ORDER
> +    #define __BYTE_ORDER  BYTE_ORDER
> +  #endif
> +  #ifndef __BIG_ENDIAN
> +    #define __BIG_ENDIAN BIG_ENDIAN
> +  #endif
> +#endif 

General note: Checking #ifdefs like this does not yield to general
portability and is very ugly overall.  Compiler and system capabilities
are subject to rather quick changes.  What if the Apple compiler does
support __BYTE_ORDER next year?

To solve this cleanly there should be a feature check in configure that
tests if the required feature is available on the system where PISA is
being compiled.  Depending on the result of this check, a definition
with a certain value should be put in config.h.  This definition can
then be used from the C code without the need to pollute the C code with
#ifdeffery.

Diego

Other related posts: