File: Cpp.chs

package info (click to toggle)
c2hs 0.28.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,772 kB
  • sloc: haskell: 6,882; ansic: 1,857; xml: 1,411; makefile: 112
file content (37 lines) | stat: -rwxr-xr-x 421 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- -*-haskell-*-

module Cpp where

import Foreign
import Foreign.C
import System.IO.Unsafe (unsafePerformIO)

-- CPP directive
-- -
#define VERSION 2


-- conditional binding
-- -
#if (VERSION == 1)

-- this does not match the C definition
--
foo :: CInt -> CInt
foo = {#call pure fooC#}

#else

-- this does
--
foo :: CInt -> CInt -> CInt
foo = {#call pure fooC#}

#endif


-- C code
-- -
#c
int fooC (int, int);
#endc