#s causing errors when -cpp not given

Simon Marlow simonmar@microsoft.com
Mon, 28 Jan 2002 12:31:35 -0000


> I've just been looking at using cpp in Haskell scripts and I am rather
> confused. I can't see anything in the report which gives=20
> special meaning
> to # in the surrounding text of literate scripts, yet if I put such
> things in (both cpp directives and random things) both nhc98 and ghc
> give me errors:
>=20
> $ rm Foo.{o,hi}; nhc98 -c Foo.lhs -o Foo.o        =20
> Unknown preprocessor directive at line 4 in file ./Foo.lhs       =20
> ifdef QQ
>=20
> $ rm Foo.{o,hi}; ghc -c Foo.lhs -o Foo.o    =20
> Foo.lhs:4: parse error on input `#'
>=20
> Are ghc and nhc98 being incompatible with Haskell 98?

GHC has one small extension to Haskell 98 in this area: the lexical
analyser interprets directives line '# 99 "Foo.hs"' at the beginning of
a line in order to get line number and file clues when it is parsing the
output from CPP.  Apart from this, '#' should be interpreted exactly as
per the report (when -fglasgow-exts is off).

Could you send us the source?

Cheers,
	Simon