Summary of current change suggestions

Fergus Henderson fjh at cs.mu.oz.au
Fri Feb 23 06:41:50 EST 2001


On 22-Feb-2001, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote:
> Thu, 22 Feb 2001 12:08:22 -0000, Simon Marlow <simonmar at microsoft.com> pisze:
> 
> > Don't forget you might need multiple includes, eg. <sys/types.h> &
> > <sys/socket.h> for socket(), and ordering is important.
> 
> Easy with my proposal:
> 
> foreign import "socket" include "<sys/types.h>" include "<sys/socket.h>"
>     socket_c :: CInt -> CInt -> CInt -> IO CInt
> 
> include options accumulate instead of being overridden.

OK, now how about things where you need to #define symbols before
including the header file?

Or where the header file to include varies depending on the system?

E.g. consider the following code.

#include "config.h"
#ifdef HAVE_SIGCONTEXT_STRUCT
  /*
  ** Some versions of Linux call it struct sigcontext_struct, some call it
  ** struct sigcontext.  The following #define eliminates the differences.
  */
  #define sigcontext_struct sigcontext /* must be before #include <signal.h> */
  struct sigcontext; /* this forward decl avoids a gcc warning in signal.h */

  /*
  ** On some systems (e.g. most versions of Linux) we need to #define
  ** __KERNEL__ to get sigcontext_struct from <signal.h>.
  */
  #define __KERNEL__
  #include <signal.h>
  #undef __KERNEL__

  /*
  ** Some versions of Linux define it in <signal.h>, others define it in
  ** <asm/sigcontext.h>.  We try both.
  */
  #ifdef HAVE_ASM_SIGCONTEXT
    #include <asm/sigcontext.h>
  #endif
#else
  #include <signal.h>
#endif

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.




More information about the FFI mailing list