File: Issue97.chs

package info (click to toggle)
c2hs 0.28.8-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,788 kB
  • sloc: haskell: 6,882; ansic: 1,857; xml: 1,411; makefile: 111
file content (17 lines) | stat: -rwxr-xr-x 369 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-- Main.chs
{-# LANGUAGE ForeignFunctionInterface #-}
module Main where

{#import Issue97A#}
import Foreign
import Foreign.C.Types
import System.IO.Unsafe (unsafePerformIO)

#include "issue97.h"

{#fun pure foo_x as fooX { `FooPtr' } -> `Int' #}

main :: IO ()
main = allocaBytes {#sizeof foo_t #} $ \fooPtr -> do
    {#set foo_t.x #} fooPtr 42
    print $ fooX fooPtr