Ashley Yakeley <[EMAIL PROTECTED]> wrote,

> 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).

If you are writing a Haskell binding to a large C library
that has hundreds of functions, it is extremely unattractive
to write "impedance matchers" like `MyModule__StringCopy'
manually.

Manuel

_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to