hsc2hs and #include

Evan Laforge qdunkan at gmail.com
Sat Jul 30 23:10:21 CEST 2011

On Sat, Jul 30, 2011 at 8:32 PM, Edward Z. Yang <ezyang at mit.edu> wrote:
> This is supposed to get defined as a command line argument to the preprocessor,
> see compiler/main/DriverPipeline.hs.  Are you saying you don't see it when you
> run hsc2hs? Maybe someone else is calling a preprocessor but missing some of
> these arguments...

Yes, I don't see it when I run hsc2hs.  I don't see how a define from
ghc is going to make it into the hsc2hs generated C file, since it
just compiles the c file with no special flags.  Looking at the hsc2hs
source, it runs the c compiler with cFlags, which I think ultimately
comes from the flags.  Since it doesn't import anything out of ghc I
don't know how it's supposed to get macros from there either, unless
that was supposed to have gone into some header.

Here's my hsc2hs line:

hsc2hs -v -c g++ --cflag -Wno-invalid-offsetof
		-Ifltk -I. -I/usr/local/src/fltk-dev/fltk-1.3/ -D_THREAD_SAFE
Executing: g++ -c Ui/Style_hsc_make.c -o Ui/Style_hsc_make.o
-Ifltk -I. -I/usr/local/src/fltk-dev/fltk-1.3/
Executing: g++ Ui/Style_hsc_make.o -o Ui/Style_hsc_make
Executing: Ui/Style_hsc_make  >Ui/Style.hs

BTW, -Wno-invalid-offsetof was necessary to get the compiler to not
complain about the C generated by the #poke and #peek macros, and with
the latest version of hsc2hs I had to explicitly tell it where the ghc
directory is... I guess it's supposed to get that out of its cabal but
I'm not sure how.

More information about the Glasgow-haskell-users mailing list