
#8222: CTYPE pragma on newtype is ignored
--------------------------+------------------------------------------------
Reporter: akio | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: | Version: 7.6.3
Compiler | Operating System: Linux
Keywords: | Type of failure: Incorrect result at runtime
Architecture: x86_64 | Test Case:
(amd64) | Blocking:
Difficulty: |
Unknown |
Blocked By: |
Related Tickets: |
--------------------------+------------------------------------------------
User's guide includes an example where a CTYPE pragma is used for a
newtype.
{{{
newtype {-# CTYPE "useconds_t" #-} T = ...
}}}
However, in the following program, the CTYPE pragma seems to be ignored:
{{{
{-# LANGUAGE CApiFFI #-}
import Foreign.Ptr
foreign import capi unsafe "sys/socket.h CMSG_DATA"
c_CMSG_DATA :: Ptr Cmsg -> Ptr a
newtype {-# CTYPE "sys/socket.h" "struct cmsghdr" #-} Cmsg = Cmsg ()
main = return ()
}}}
Save this as {{{capi.hs}}}, then compile it like:
{{{
ghc capi.hs -fforce-recomp -keep-tmp-files -tmpdir .
}}}
Then GHC creates a C file:
{{{
#define IN_STG_CODE 0
#include "Rts.h"
#include "Stg.h"
#ifdef __cplusplus
extern "C" {
#endif
#include