[Haskell-cafe] Re: [Haskell] Does GHC support the standard CPP
functionalities?
Malcolm Wallace
malcolm.wallace at cs.york.ac.uk
Sat Nov 22 05:13:39 EST 2008
[moved to haskell-cafe]
> {-# LANGUAGE CPP #-}
>
> module Packer where
>
> #define FLASH_APP_START 1
> #define FLASH_APP_END 2
> #define INSERT_SECTION(x) (#x, (FLASH_##x##_START, FLASH_##x##_END))
The CPP stringization operator # and the token-catenation operator ##
are ANSI additions over the traditional K+R CPP. Ghc uses the -
traditional flag to exclude them, because both # and ## are valid
Haskell operators, and most people would not want them to be removed
by the CPP preprocessor.
There are also some other lexical differences between Haskell and C
which make it a good ides for ghc to use cpp -traditional.
However, if you really want to use ANSI additions, you can switch to
cpphs,
which does know about the lexical syntax of Haskell.
http://haskell.org/cpphs
To use it with ghc, you will need to pass the following extra options:
ghc -cpp -pgmPcpphs -optP--cpp -optP-ansi
Unfortunately, I'm not certain I can guarantee that the -ansi flag
will take effect - it depends on whether ghc internally adds the -
traditional argument before or after it.
Regards,
Malcolm
More information about the Haskell-Cafe
mailing list