Open joeyh opened 10 years ago
Hmm... I don't really have the context for this, but it sounds like haskell-src-exts is not understanding /* ... */ comments correctly. Do you think patching haskell-src-exts would be the best overall solution here?
/* .. */ is not a valid haskell comment, so it does not seem right for haskell-src-exts to support it.
At least with my version of ghc (7.6.3), when cabal runs ghc with the parameters "-optP-include","-optPdist/build/autogen/cabal_macros.h", ghc in turns runs cpp (not cpphs), and in this case, cpp strips out the C-style comments while preprocessing. This is why ghc does not have trouble with those comments.
Ah, cpphs has a way to do this comment stripping too: --cpp -traditional.
So, this works: hothasktags -c --cpp -c -traditional -c --include=dist/build/autogen/cabal_macros.h
But is quite a mouthful, and not easy to work out. Perhaps hothasktags could have an option to make it use the cabal macros and enable those options?
With cabal's new v2 commands, an easier way to run hothasktags is:
cabal exec hothasktags -- --cpp
That makes it find the cabal_macros.h and generally use the same stuff cabal used to build the package. It seems the --cpp is still necessary, as is enabling with -X any extensions that the cabal file has in Default-Extensions.
Thanks for this information
I'm having problems like this:
hothasktags: Cannot expand #if directive in file Annex.hs at line 83 col 1: MIN_VERSION_exceptions(a,b,c) is not a defined macro
(Oddly, earlier versions of hothasktags seemed to work.)
While I can work around with with -D 'MIN_VERSION_exceptions(1,1,1)', new version macros are added from time to time..
Seems that the solution could be to -c --include=dist/build/autogen/cabal_macros.h to get all the macros. But that fails:
Parse error: SrcLoc {srcFilename = "./dist/build/autogen/cabal_macros.h", srcLine = 1, srcColumn = 1}: Parse error: /*
The problem is the /* */ comments in the file.
I have worked around that by preprocessing the .h file before calling hothasktags, to remove the comments.