Language extensions - backwards compatibility
Iain Alexander
ia at stryx.demon.co.uk
Fri Jan 29 20:32:56 EST 2010
On 29 Jan 2010 at 15:14, Malcolm Wallace <Malcolm.Wallace at cs.york.ac.uk> wrote:
> > The flag -P for traditional gnu cpp (or --noline for stand-alone
> > cpphs) should suppress the initial #line noise.
> >
> > Does ghc still fail to recognise a module-start pragma, even if the
> > only characters preceding it are whitespace?
I'm not sure, but ghci apparently fails to recognise a file-header pragma if it
is preceded by a {-# LINE ... #-} pragma.
>
> I intended to give an example.
>
> ---- file foo.h ----
> #if __GLASGOW_HASKELL__ == 604
> #define PRAGMA(foo) {-# OPTIONS_GHC -X foo #-}
> #else
> #define PRAGMA(foo) {-# LANGUAGE foo #-}
>
> ---- file Bar.hs ----
> #include "foo.h"
> PRAGMA(MyLanguageOption)
> module Bar where
>
> ---- result ----
> $ ghc-6.8.2 -E -cpp -optP-P Bar.hs
> $ cat Bar.hspp
> {-# LINE 1 "Bar.hs" #-}
How on earth does the *C* preprocessor manage to insert a *Haskell* {-# LINE
... #-} pragma? (I see that myself as well in some configurations, some cpphs
(which I could understand), but some not.)
>
>
>
> {-# LANGUAGE MyLanguageOption #-}
> module Bar where
>
> $ ghc-6.4.1 -E -cpp -optP-P Bar.hs
> $ cat Bar.hspp
>
> {-# OPTIONS_GHC -X MyLanguageOption #-}
> module Bar where
>
--
Iain Alexander ia at stryx.demon.co.uk
More information about the Glasgow-haskell-users
mailing list