Ptr and ForeignPtr Questions
Ashley Yakeley
ashley@semantic.org
Sun, 23 Sep 2001 15:58:19 -0700
At 2001-09-23 04:04, Marcin 'Qrczak' Kowalczyk wrote:
>It would be impossible then to directly call a C function with a
>parameter declared as a const pointer. It's illegal in C to have
>mismatching prototypes of the same function.
You can always do this:
module MyModule where
{
foreign import StringCopy :: Ptr Int8 -> Ptr Int8 -> IO ();
}
which autogenerates this header:
extern "C"
{
void MyModule__StringCopy(signed char* a,signed char* b);
}
which the user can implement like this:
char* strcat(char* dest, const char* src);
void MyModule__StringCopy(char* dest,char* src)
{
strcat(dest,src);
}
(assuming char and signed char are identical).
--
Ashley Yakeley, Seattle WA