lukexi / halive

Live recompiler for Haskell
BSD 2-Clause "Simplified" License
263 stars 18 forks source link

CPP statements cause error on startup #16

Closed schell closed 7 years ago

schell commented 7 years ago

Hey there - it seems that when using halive the c preprocessor is erring at a (pretty common) macro in my program:

██╗  ██╗ █████╗ ██╗     ██╗██╗   ██╗███████╗
██║  ██║██╔══██╗██║     ██║██║   ██║██╔════╝
███████║███████║██║     ██║██║   ██║█████╗  
██╔══██║██╔══██║██║     ██║╚██╗ ██╔╝██╔══╝  
██║  ██║██║  ██║███████╗██║ ╚████╔╝ ███████╗
╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═══╝  ╚══════╝
                  engaged

src/Control/Varying/Spline.hs:105:21:
     error: token is not a valid binary operator in a preprocessor subexpression
#if MIN_VERSION_base(4,8,0)
    ~~~~~~~~~~~~~~~~^
1 error generated.

maybe I should be passing in some extra data on the command line? Or maybe CPP isn't supported yet? Compilation through stack is working, it's only halive that encounters the error.

lukexi commented 7 years ago

Hmm are you using LANGUAGE pragmas or is CPP added in the cabal file? It won't pick those up (but I'd like to do that!). Passing along flags to GHC is high on the list too :))

If you use the '{-# LANGUAGE CPP #-}' style I think it should work! Let me know... will test as soon as I'm back at the computer!

Sent from my iPhone

On Sep 10, 2016, at 7:03 AM, Schell Carl Scivally notifications@github.com wrote:

Hey there - it seems that when using halive the c preprocessor is erring at a (pretty common) macro in my program:

██╗ ██╗ █████╗ ██╗ ██╗██╗ ██╗███████╗ ██║ ██║██╔══██╗██║ ██║██║ ██║██╔════╝ ███████║███████║██║ ██║██║ ██║█████╗
██╔══██║██╔══██║██║ ██║╚██╗ ██╔╝██╔══╝
██║ ██║██║ ██║███████╗██║ ╚████╔╝ ███████╗ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚══════╝ engaged

src/Control/Varying/Spline.hs:105:21: error: token is not a valid binary operator in a preprocessor subexpression

if MIN_VERSION_base(4,8,0)

~~~~~~~~~~~~~~~~^

1 error generated. maybe I should be passing in some extra data on the command line? Or maybe CPP isn't supported yet? Compilation through stack is working, it's only halive that encounters the error.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

schell commented 7 years ago

@lukexi I'm using {-# LANGUAGE CPP -#} at the top of my file. I'll try both.

lukexi commented 7 years ago

Oop, just remembered to check this and it's working here!

{-# LANGUAGE CPP #-}
#if MIN_VERSION_base(4,8,0)
#define END 11
#else
#define END 12
#endif
main = print [1..END]
SubHalive recompiling: ("demo/Computation.hs","main")
[1,2,3,4,5,6,7,8,9,10,11]

This is on HEAD - are you using that or the hackage version? (planning on a new release soon!)

schell commented 7 years ago

I was using HEAD. I'll try to pull newest, recompile and check some time today :)