Cabal Preprocessor Defines

Manuel Schneckenreither manuel.schneckenreither at student.uibk.ac.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 ]
     #else
            [ppSig sig | sig <- filter ((\(_,_,r) -> not r) . lhsRootSym) sigs ]
     #endif
            ...

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
or

    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
          else
              CC-Options: -DNDEBUG

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


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


Thanks for your reply,

Manuel


--
To reply secure use GnuPG encryption:
Key Block to use (http://www.pinselzone.com/pgp/public_gpg_key.asc)
What is GnuPG? (http://www.gnupg.org/)


More information about the cabal-devel mailing list