freeHaskellFunctionPtr
Fergus Henderson
fjh at cs.mu.oz.au
Tue Jan 2 09:48:00 EST 2001
On 02-Jan-2001, Marcin 'Qrczak' Kowalczyk <mk167280 at zodiac.mimuw.edu.pl> wrote:
>
> Null function pointers are a non-portable concept - ANSI C does not have
> them, only null data pointers. But many existing C interfaces use them,
You're mistaken -- ANSI/ISO C definitely does have null function pointers.
So it's not suprising that many existing C interfaces use them.
> and even the ability to cast between data pointers and function pointers
> is described as a common non-standard extension in ISO/ANSI C99.
That's true. ANSI/ISO C does not guarantee that a data pointer will
fit in a function pointer or vice versa.
If you want something that could be either a data pointer or
a function pointer, you need to use a union:
union {
void *data;
void (*func)(void);
}
--
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