Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to include cabal macros #18

Open
joeyh opened this issue Jun 30, 2014 · 4 comments
Open

how to include cabal macros #18

joeyh opened this issue Jun 30, 2014 · 4 comments

Comments

@joeyh
Copy link
Contributor

joeyh commented Jun 30, 2014

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.

@luqui
Copy link
Owner

luqui commented Jul 1, 2014

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?

@joeyh
Copy link
Contributor Author

joeyh commented Jul 1, 2014

/* .. */ 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?

@joeyh
Copy link
Contributor Author

joeyh commented Jun 18, 2020

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.

@luqui
Copy link
Owner

luqui commented Jun 19, 2020

Thanks for this information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants