Open claudeha opened 9 years ago
typedef int * bug; becomes type C'bug = CInt instead of type C'bug = Ptr CInt:
typedef int * bug;
type C'bug = CInt
type C'bug = Ptr CInt
$ c2hsc --version
c2hsc v0.6.4, (C) John Wiegley 2012
$ cat bug.h
$ c2hsc --prefix "Pointer" bug.h
Wrote Bug.hsc
$ cat Bug.hsc
{-# OPTIONS_GHC -fno-warn-unused-imports #-} #include <bindings.dsl.h> #include "bug.h" module Pointer.Bug where import Foreign.Ptr #strict_import {- typedef int * bug; -} #synonym_t bug , CInt
$ hsc2hs Bug.hsc
$ cat Bug.hs
{-# LINE 1 "Bug.hsc" #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# LINE 2 "Bug.hsc" #-} {-# LINE 3 "Bug.hsc" #-} {-# LINE 4 "Bug.hsc" #-} module Pointer.Bug where import Foreign.Ptr import Foreign.Ptr (Ptr,FunPtr,plusPtr) import Foreign.Ptr (wordPtrToPtr,castPtrToFunPtr) import Foreign.Storable import Foreign.C.Types import Foreign.C.String (CString,CStringLen,CWString,CWStringLen) import Foreign.Marshal.Alloc (alloca) import Foreign.Marshal.Array (peekArray,pokeArray) import Data.Int import Data.Word {-# LINE 7 "Bug.hsc" #-} {- typedef int * bug; -} type C'bug = CInt {-# LINE 10 "Bug.hsc" #-}
This works at the time of writing
C
typedef const PCRE2_UCHAR8 *PCRE2_SPTR8;
HSC
#globalvar PCRE2_SPTR8 , Ptr CUChar
not sure if it's because it's const or this bug is just fixed now
typedef int * bug;
becomestype C'bug = CInt
instead oftype C'bug = Ptr CInt
:$ c2hsc --version
$ cat bug.h
$ c2hsc --prefix "Pointer" bug.h
$ cat Bug.hsc
$ hsc2hs Bug.hsc
$ cat Bug.hs