rubik / argon

Monitor cyclomatic complexity in Haskell programs
BSD 3-Clause "New" or "Revised" License
97 stars 8 forks source link

fails to parse CPP testing MIN_VERSION... #15

Closed simonmichael closed 8 years ago

simonmichael commented 9 years ago
#if !MIN_VERSION_base(4,8,0)

gives:

error: 67:22  error: token is not a valid binary operator in a preprocessor subexpression

(context)

rubik commented 9 years ago

Yeah, this is a known issue. Those marcros are provided by Cabal, so the preprocessor does not recognize them. I have yet to find a way to make it work. We were discussing some solutions here: #14

rubik commented 8 years ago

This is the function we need: http://haddock.stackage.org/lts-3.10/Cabal-1.22.4.0/Distribution-Simple-BuildPaths.html#v:autogenModulesDir

It gives the path to the autogenerated modules directory, which contains, among other things, the cabal_macros.h file that we need. The problem now is how to get the LocalBuildInfo object.

rubik commented 8 years ago

I confirmed that this bug is fixed with when using the new option --cabal-macros. If you are using Stack, it's as easy as:

$ argon --cabal-macros $(stack path --dist-dir)/build/autogen/cabal_macros.h src

If instead you are using pure Cabal I don't know the exact path. That header file is generated during cabal build, so one has to be sure to have it up-to-date when passing it to Argon. The change has already been pushed to master, and will be included in the upcoming 0.4.0.0 version.