Add support for ASM foreign files (.s) in TH (#16180)
[ghc.git] / testsuite / tests / th / T16180.hs
1 {-# LANGUAGE TemplateHaskell #-}
2
3 module Main where
4
5 import Language.Haskell.TH.Syntax
6 import Foreign.C.String
7
8 $(do
9 -- some architectures require a "_" symbol prefix...
10 -- GHC defines a LEADING_UNDERSCORE CPP constant to indicate this.
11 addForeignSource LangAsm
12 "#if defined(LEADING_UNDERSCORE)\n\
13 \.global \"_mydata\"\n\
14 \_mydata:\n\
15 \#else\n\
16 \.global \"mydata\"\n\
17 \mydata:\n\
18 \#endif\n\
19 \.ascii \"Hello world\\0\"\n"
20 return [])
21
22 foreign import ccall "&mydata" mystring :: CString
23
24 main :: IO ()
25 main = putStrLn =<< peekCString mystring