[C2hs] available.h on Mac (bug #6)

John Lato jwlato at gmail.com
Wed Jul 23 13:44:55 EDT 2008

On Wed, Jul 23, 2008 at 6:07 AM, Duncan Coutts
<duncan.coutts at worc.ox.ac.uk> wrote:
> On Wed, 2008-07-23 at 00:50 -0500, John Lato wrote:
>> Hello,
>> I recently ran up against bug #6 on a Mac (Leopard 10.5.2, c2hs
>> .15.1).  This results in the error
>> c2hs: Error in C header file.
>> /usr/include/available.h:85: (column 5) [FATAL]
>> >>> Lexical error! The character '#' does not fit here.
>> I added some information to the bug report based on my
>> experimentation, and would like to say that I've found a workaround.
>> By running c2hs with these options:
>> --cpp=gcc --cppopts=-E --cppopts=-xc
>> I was able to successfully build the interface.  This works with cabal
>> builds as well by passing the options during configure with
>> --c2hs-options.
>> I'm pretty certain that this is due to some sort of failure in Apple's
>> cpp and not a problem with c2hs.  Can anyone else confirm this?
> We've had problems with this before. The current c2hs cpp code uses:
> cppopts :: String
> cppopts  = case os of
>  -- why is gcc different between all these platforms?
>  "darwin"  -> "-x=c"
>  "openbsd" -> "-xc"
>  _         -> "-x c"
> So we had previously had reported that using -x=c worked on OSX. Does
> that not work for you now?
> Ie using: c2hs --cpp=cpp --cppopts=-x=c
> or perhaps: c2hs --cpp=cpp --cppopts=-xc
> Duncan

No, unfortunately neither of those work for me with
i686-apple-darwin9-gcc-4.0.1 (Apple build 5465) on 10.5.4.
I'm not sure that any arguments to cpp will make it work (for this
particular cpp).  Even when I made a simple .h file that just copied
the offending lines from available.h and tried to run it through cpp
(using the appropriate -D flags), it still didn't seem to create the
correct output.  It's very possible that I'm overlooking something as
I'm not very familiar with cpp, but I think it's odd that cpp output
differs from gcc -E.

More information about the C2hs mailing list