Closed nh2 closed 10 years ago
Also it might be interesting to note that in https://github.com/jwiegley/c2hsc/blob/cc4d02/Main.hs#L388 all declSpecs
are traversed in reverse.
I think the issue is in
-- If the type is a typedef, record the equivalence so we can
-- look it up later
case declSpecs of
CStorageSpec (CTypedef _):_ -> do
when (declMatches fm dx) $ do
appendHsc $ "{- " ++ P.render (pretty dx) ++ " -}"
appendType declSpecs nm
dname <- declSpecTypeName declSpecs
unless (null dname || dname == "<" ++ nm ++ ">") $ do
when (declMatches fm dx) $
appendHsc $ "#synonym_t " ++ nm ++ " , " ++ dname
The appendType
is the part that emits the #opaque_t
for the typedef. Should that even happen for a typedef, or should #synonym_t
be the only thing emitted from it?
I think these are some cases we have to deal with:
struct MyTypeImpl;
typedef struct MyTypeImpl* MyType;
typedef struct MyStruct {
int x;
} MyStructType;
typedef struct MyStructEmpty MyStructEmptyType;
Well, if the typedef actually declares the type, we need to omit it; but if it was previously declared, we shouldn't. I think I'll have to keep a table to recall which types have been seen as declared already.
nh2: working now
I mean, @nh2 :)
Thanks!
bug.hs
:Then run
c2hsc --prefix=Bug bug.h
.We obtain:
Notice the duplicate
#opaque_t struct MyTypeImpl