Cabal Preprocessor Defines

Manuel Schneckenreither manuel.schneckenreither at
Thu Sep 18 00:21:10 UTC 2014

Hi all,

I got some prepocessor constrains in one of my library I use for my new
project. The section look like this:

     #ifdef DEBUG
            [ppSig sig | sig <- sigs ]
            [ppSig sig | sig <- filter ((\(_,_,r) -> not r) . lhsRootSym) sigs ]

Due to the reason that I am still developing wanted to specify the DEBUG
preprocessor symbol to cpphs, gcc, ghc, or whatever program needs it. My
suggestion was that cpphs should handle these definitions. So I tried
several things, like:

    cabal configure --cpphs-options="--cpp -DDEBUG"
        --ghc-options=-DDEBUG --gcc-options=-DDEBUG && cabal build
        && cabal install

    cabal configure --cpphs-options="-DDEBUG"
        --ghc-options=-DDEBUG --gcc-options=-DDEBUG && cabal build
        && cabal install

    cabal configure && cabal build  --cpphs-options="--cpp -DDEBUG"
        --cpphs-options=-DDEBUG --gcc-options=-DDEBUG && cabal install

I tried it also in the cabal file:

      default-extensions: CPP   -- also tried with other-extensions
      if flag(debug)
          CPP-Options: -DDEBUG
          if !os(windows)
              CC-Options: -DDEBUG
              CC-Options: -DNDEBUG

and compiling with cabal configure --flags=debug && cabal build && cabal

None of them worked. Am I doing it wrong, or is there something wrong
with cabal, cpphs, ghc, etc.

Thanks for your reply,


To reply secure use GnuPG encryption:
Key Block to use (
What is GnuPG? (

More information about the cabal-devel mailing list