hsc2hs and Windows line endings on linux
There seems to be a problem when compiling a file under Linux which has Windows line endings and uses #let 's in the file.
A simple example would be
module Main where
#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
main :: IO ()
main = return ()
which does nothing really, but should compile.
this fails under linux (when the file was saved using windows line endings) with the error
1.Broken.hsc:4: error: expected identifier or ‘(’ before ‘)’ token
2.compiling Broken_hsc_make.c failed
looking at the generated .c file
4.#include "/usr/lib/ghc-6.12.1/template-hsc.h"
5.#line 3 "Broken.hsc"
6.#define hsc_alignment(t ) printf ( "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
7.);
8. <truncated>
on line 6 the closing ");" was pushed to a new line, 7, but this causes the define to end unexpectedly and cauzes the syntax error mention above. This is presumably because only the "\n" and the "\r" are left in there.
also the generated code contains a mixture of both endings, which is no problem for ghc and gcc but might be for some editors:
18. fputs ("\r\n"
19. "", stdout);
20. fputs ("\n"
21. "", stdout);