summaryrefslogtreecommitdiff
path: root/testsuite/tests/driver/T16737.hs
blob: daf830693b5d10f6e30d69d247ad625eda5c63fb (plain)
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
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -DFOO=2 -optP=-DBAR=3 -optc=-DBAZ=5 -optcxx=-DBAZ=7 #-}

import Language.Haskell.TH.Syntax

do
  let code = unlines
        [ "#if defined(__cplusplus)"
        , "extern \"C\" {"
        , "#endif"
        , "#include <T16737.h>"
        , "int FUN(void) {"
        , "  return FOO * BAR * BAZ;"
        , "}"
        , "#if defined(__cplusplus)"
        , "}"
        , "#endif"
        ]
  addForeignSource LangC code
  addForeignSource LangCxx code
  pure []

foreign import ccall unsafe "c_value"
  c_value :: IO Int

foreign import ccall unsafe "cxx_value"
  cxx_value :: IO Int

main :: IO ()
main = do
  print =<< c_value
  print =<< cxx_value