[C2hs] c2hs extracts "Ptr ()" instead of pointer hook name

Thomas Strobel ts468 at cam.ac.uk
Mon Jul 8 14:08:02 CEST 2013


Dear All,

I'm trying to write a FFI for the Enlightenment Foundation Libraries,
but my small example of a binding fails to compile, and I wanted to ask
if someone would have some advice for me how to make c2hs extract the
correct bindings.

Many thanks in advance!

  Thomas


My program's code is:

{-# LANGUAGE ForeignFunctionInterface #-}

import Foreign.Ptr
#include <Ecore_Evas.h>

{#pointer *Ecore_Evas as EcoreEvas newtype#}
{#pointer *Evas as Evas newtype#}

{#fun ecore_evas_get {id `EcoreEvas'} -> `Evas' id#}


The signature of the C function is:
https://build.enlightenment.org/job/nightly_efl_gcc_x86_64/lastSuccessfulBuild/artifact/doc/html/group__Ecore__Evas__Group.html#ga21b6108d757f0aea6c4126d59cfb8826


The trace of c2hs is:

-C "-I/usr/local/include/ecore-1" -C "-I/usr/local/include/ecore-evas-1"
-C "-I/usr/local/include/evas-1" -C "-I/usr/local/include/efl-1" -C
"-I/usr/local/include/eina-1" -C "-I/usr/local/include/eina-1/eina" -C
"-I/usr/local/include/eo-1" 
** Pointer hook:
found C declaration for `Ecore_Evas'
extractCompType: checking for alias
extracted ptr type is `()'
associated with Haskell entity `EcoreEvas'
having type ()
** Pointer hook:
found C declaration for `Eo'
extractCompType: checking for alias
extracted ptr type is `()'
associated with Haskell entity `Evas'
having type ()
** Fun hook for `get':
Entering `extractSimpleType' (for a result)...
extractCompType: explicit pointer type
extractCompType: checking for alias
extractCompType: found an alias called `Evas'
extractCompType: checking for alias
extractCompType: found an alias called `Eo'
extractCompType: checking for alias
Entering `extractSimpleType' (not for a result)...
extractCompType: explicit pointer type
Imported function type: ((EcoreEvas) -> (IO (Ptr ())))
Entering `extractSimpleType' (for a result)...
extractCompType: explicit pointer type
extractCompType: checking for alias
extractCompType: found an alias called `Evas'
extractCompType: checking for alias
extractCompType: found an alias called `Eo'
extractCompType: checking for alias
Entering `extractSimpleType' (not for a result)...
extractCompType: explicit pointer type
Marshalling specification including defaults: 
  id `EcoreEvas' void-
  void- `Evas' id
  The marshalling is pure.


The compilation of the generated .hs-file fails with:

[1 of 1] Compiling Evas             ( Evas.hs, Evas.o )

Evas.chs:22:11:
    Couldn't match expected type `Evas' with actual type `Ptr ()'
    In the first argument of `return', namely `(res')'
    In the expression: return (res')
    In the expression: let res' = id res in return (res')






More information about the C2hs mailing list