Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Strorable and incomplete type (PICCA Frederic-Emmanuel)


----------------------------------------------------------------------

Message: 1
Date: Mon, 27 Jun 2016 16:49:46 +0000
From: PICCA Frederic-Emmanuel
        <frederic-emmanuel.pi...@synchrotron-soleil.fr>
To: "beginners@haskell.org" <beginners@haskell.org>
Subject: [Haskell-beginners] Strorable and incomplete type
Message-ID:
        
<a2a20ec3b8560d408356cac2fc148e53b307f...@sun-dag3.synchrotron-soleil.fr>
        
Content-Type: text/plain; charset="Windows-1252"

Hello,

I would like to use Storable and declare an instance for a struct available in 
a C library

instance Storable Parameter where
    sizeOf _ = #{size HklParameter}
    peek ptr = alloca $ \pmin ->
               alloca $ \pmax -> do
                              cname <- c_hkl_parameter_name_get ptr
                              name <- peekCString cname
                              value <- c_hkl_parameter_value_get ptr unit
                              c_hkl_parameter_min_max_get ptr pmin pmax unit
                              min <- peek pmin
                              max <- peek pmax
                              return (Parameter name value (Range min max))


but when I try to compile this, I get this error message

C.hsc:507:15: error: invalid application of ‘sizeof’ to incomplete type 
‘HklParameter’

Indeed the C library do not expose this struct internal.

So I would like to know how to handle this kind of C struct with Storable.

thanks for your help

Frédéric

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 96, Issue 17
*****************************************

Reply via email to