Whitespace required when using a clang-compiled Alex with gcc #37

merged 2 commits into from Nov 19, 2013

2 participants


To the untrained eye (mine), this all seems a bit weird. But here is fix for #36 (and the GHC ticket https://ghc.haskell.org/trac/ghc/ticket/8528).

I think whenever the ALEX_IF_GHC* macros are used, a blank line needs to precede them.

To reproduce the error and verify the fix:

  1. On Mac OS X mavericks, install the xcode command line utilities, and Haskell Platform 2013.2.0.0. gcc will now really be clang.
  2. Install gcc48 from homebrew (or otherwise). It should not replace the gcc on your path.

Use a shim for gcc to enable switching (this is my ~/bin/gcc)

/usr/bin/gcc $@

Check gcc, for now it should be clang:

gcc --version
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)

Build and test:

$ cd /path/to/alex
$ cabal configure --enable-tests
$ cabal build
$ ./dist/build/tests/tests # Passes

Now switch gcc over to a real gcc:

/usr/bin/gcc-4.8 $@

And run tests again (without recompiling!)

$ gcc --version
gcc-4.8 (GCC) 4.8.2
$ ./dist/build/tests/tests

Observe all the errors. Like this one:

error: #else without #if
-- INTERNALS and main scanner engine

With this patch these go away. For now. This is all pretty messy and easy to break in the future. There might be another way that works.

@nkpart nkpart referenced this pull request in simonmar/happy Nov 18, 2013

Fixes for clang-compiled happy being used with GCC #12


Could the blank line contain a comment? Or failing that, a comment preceding the blank line to avoid someone removing it in the future would be good.


Looks good. Thanks!

@simonmar simonmar merged commit 097eb59 into simonmar:master Nov 19, 2013

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment