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:
Use a shim for gcc to enable switching (this is my ~/bin/gcc)
Check gcc, for now it should be clang:
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:
And run tests again (without recompiling!)
$ gcc --version
gcc-4.8 (GCC) 4.8.2
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.
Necessary preceding whitespace when compiling code with gcc, but usin…
…g an alex compiled with clang
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.
Adds a comment where the blank lines are required
Looks good. Thanks!