#6132: Can't use both shebang line and #ifdef declarations in the same file.
---------------------------------------+------------------------------------
Reporter: gfxmonk | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.0.4 | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: GHC rejects valid program | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------------+------------------------------------
I have an (admittedly awkward) script which can be compiled or
interpreted.
If it's compiled, I want the full goodness. If it's interpreted, I want to
run a "minimal" version (because if I don't have the compiled version, I
probably don't have the required libraries either).
The following almost works:
{{{
module Main (main) where
#ifdef FANCY
import qualified System.Console.ANSI as Term
start = Term.setSGR [Term.SetColor Term.Foreground Term.Dull Term.Green]
end = Term.setSGR []
#else
start = return ()
end = return ()
#endif
main :: IO ()
main = do
start
putStrLn "hello world"
end
}}}
and then I can do:
{{{
$ runghc -cpp main.hs
hello world
^^ plain text
}}}
{{{
$ ghc -O -cpp -DFANCY main.hs
$ ./main
hello world
^^ green text (a.k.a "fancy")
}}}
I attempted to make this directly runnable by adding a shebang line of
{{{
#!/usr/bin/runghc -cpp
}}}
But unfortunately that chokes with -cpp:
{{{
$ ghc -O -cpp -DFANCY main.hs
main.hs:1:0: error: invalid preprocessing directive #!
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6132>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs