Parse error when #ifdef pragma enabled

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Parse error when #ifdef pragma enabled

Rob Stewart-2
Hi,

I'm missing something obvious. I'd like to compile the following code.

--8<---------------cut here---------------start------------->8---
{-# LANGUAGE CPP #-}

module CPP where

#ifdef CUDA
import qualified Data.Array.Accelerate.CUDA as CUDA
#endif

f = "lolcats"
--8<---------------cut here---------------end--------------->8---

Without the CUDA pragma, it's all good:

$ ghc --make CPP.hs
[1 of 1] Compiling CPP              ( CPP.hs, CPP.o )

With the pragma thought, I get a compilation error:

$ ghc --make CPP.hs -DCUDA
[1 of 1] Compiling CPP              ( CPP.hs, CPP.o )
CPP.hs:6:39: parse error on input `.'

Where's my mistake?

Thanks!

--
Rob
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Parse error when #ifdef pragma enabled

Sylvain HENRY
CUDA is substituted in
> import qualified Data.Array.Acceletare.*CUDA* as *CUDA*
with nothing.

-Sylvain


2014-04-28 21:17 GMT+02:00 Rob Stewart <[hidden email]>:
Hi,

I'm missing something obvious. I'd like to compile the following code.

--8<---------------cut here---------------start------------->8---
{-# LANGUAGE CPP #-}

module CPP where

#ifdef CUDA
import qualified Data.Array.Accelerate.CUDA as CUDA
#endif

f = "lolcats"
--8<---------------cut here---------------end--------------->8---

Without the CUDA pragma, it's all good:

$ ghc --make CPP.hs
[1 of 1] Compiling CPP              ( CPP.hs, CPP.o )

With the pragma thought, I get a compilation error:

$ ghc --make CPP.hs -DCUDA
[1 of 1] Compiling CPP              ( CPP.hs, CPP.o )
CPP.hs:6:39: parse error on input `.'

Where's my mistake?

Thanks!

--
Rob
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Parse error when #ifdef pragma enabled

Robert Vollmert
In reply to this post by Rob Stewart-2

On Apr 28, 2014, at 21:17 , Rob Stewart <[hidden email]> wrote:

> I'm missing something obvious. I'd like to compile the following code.
>
> --8<---------------cut here---------------start------------->8---
> {-# LANGUAGE CPP #-}
>
> module CPP where
>
> #ifdef CUDA
> import qualified Data.Array.Accelerate.CUDA as CUDA
> #endif
>
> f = "lolcats"
> --8<---------------cut here---------------end--------------->8---
>
> Without the CUDA pragma, it's all good:
>
> $ ghc --make CPP.hs
> [1 of 1] Compiling CPP              ( CPP.hs, CPP.o )
>
> With the pragma thought, I get a compilation error:
>
> $ ghc --make CPP.hs -DCUDA
> [1 of 1] Compiling CPP              ( CPP.hs, CPP.o )
> CPP.hs:6:39: parse error on input `.'
>
> Where's my mistake?

You’re defining ‘CUDA’ to be replaced by the empty string, so after running through CPP, you’ll have

module CPP where
import qualified Data.Array.Accelerate. as

(Haven’t actually tested this, but it’s what cpp should do, and explains the error message nicely.)

Try using ‘-DWITHCUDA’ or something similar?

Cheers
Rob
 
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Parse error when #ifdef pragma enabled

Rob Stewart-2
Hi Rob,

On 28 April 2014 20:32, Robert Vollmert <[hidden email]> wrote:

> You’re defining ‘CUDA’ to be replaced by the empty string, so after running through CPP, you’ll have
>
> module CPP where
> import qualified Data.Array.Accelerate. as
>
> (Haven’t actually tested this, but it’s what cpp should do, and explains the error message nicely.)
>
> Try using ‘-DWITHCUDA’ or something similar?

Works as you might expect, thanks!

--
Rob
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe