summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/T13366C.hs
blob: 246687dcf0947a90f668237b4af4b0f240c7d813 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -optc-DA_MACRO=1 -optcxx-DA_MACRO=1 #-}

import Language.Haskell.TH.Syntax
import System.IO (hFlush, stdout)

foreign import ccall fc :: Int -> IO Int

do addForeignSource LangC $ unlines
     [ "#include <stdio.h>"
     , "int fc(int x) {"
     , "  printf(\"calling f(%d)\\n\",x);"
     , "  fflush(stdout);"
     , "  return A_MACRO + x;"
     , "}"
     ]
   return []

main :: IO ()
main = do
  fc 2 >>= print
  hFlush stdout