[C2hs] [c2hs] #9: sizeof computation fails for nested derived types (pointer to array or array of pointers)
c2hs
cvs-ghc at haskell.org
Thu Jan 20 01:39:31 CET 2011
#9: sizeof computation fails for nested derived types (pointer to array or
array of pointers)
--------------------+-------------------------------------------------------
Reporter: guest | Type: defect
Status: new | Priority: normal
Milestone: | Component: general
Version: 0.15.1 | Keywords:
--------------------+-------------------------------------------------------
Comment(by guest):
I think this may be related:
bug.h
{{{
typedef char inner_t[32];
typedef struct
{
inner_t first;
inner_t second;
} outer_t;
}}}
bug.chs
{{{
module Bug where
#include "bug.h"
main :: IO ()
main = print ({# sizeof inner_t #}, {# sizeof outer_t #})
}}}
Running c2hs bug.chs (on a 64-bit machine) gives me…
{{{
module Bug where
main :: IO ()
main = print (32, 16)
}}}
Shurely schome mischtake?
On the other hand,
okay.h
{{{
typedef struct
{
char first[32];
char second[32];
} outer_t;
}}}
okay.chs
{{{
module Okay where
#include "okay.h"
main :: IO ()
main = print {# sizeof outer_t #}
}}}
gives…
{{{
module Okay where
main :: IO ()
main = print 64
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/c2hs/ticket/9#comment:1>
c2hs <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/>
C->Haskell, An Interface Generator for Haskell
More information about the C2hs
mailing list