[Alessandro Vernet <[EMAIL PROTECTED]> asks about problems using a
preprocessor with Hugs.]
The Hugs distribution includes the following (at the end of the
Install file). I haven't used the script in a while but it used to
work quite well. If I remember correctly, the use of -traditional is
critical when invoking gcc since it affects what cpp does with
identifiers like a' which appear to be incomplete character constants
(when interpreted as C programs).
Hope this helps
Alastair Reid
--with-preprocessor
This is an experimental feature and may change in future versions.
Enable the use of a preprocessor for processing Haskell source files
before compiling them with Hugs. When configured with preprocessing
on, you can use the "-F" option to specify which preprocessor to use.
For example, if your preprocessor is in /users/JFH/bin/hscpp, you might
say
:set -F"/users/JFH/bin/hscpp"
If you have perl and gcc installed on your machine, the following
script provides a simple cpp-like preprocessor.
eval "exec perl -S $0 $*"
if $running_under_some_random_shell;
#
# Reads CPP output and turns #line things into appropriate Haskell
# pragmas. This program is derived from the "hscpp" script
# distributed with the Glasgow Haskell Compiler.
#
$Cpp = 'gcc -E -xc -traditional';
open(INPIPE, "$Cpp @ARGV |") || die "Can't open C pre-processor pipe\n";
while (<INPIPE>) {
# line directives come in flavo[u]rs:
# s/^#\s*line\s+\d+$/\{\-# LINE \-\}/; IGNORE THIS ONE FOR NOW
s/^#\s*line\s+(\d+)\s+(\".+\")$/\{\-# LINE \1 \2 \-\}/;
s/^#\s*(\d+)\s+(\".*\").*/\{\-# LINE \1 \2 \-\}/;
print $_;
}
close(INPIPE) || exit(1); # exit is so we reflect any errors.
exit(0);
Note that Hugs currently ignores the {-# LINE _ _ #-} pragmas so error
messages will refer to the wrong line numbers.