From jwlato at gmail.com Wed Jul 23 01:50:23 2008 From: jwlato at gmail.com (John Lato) Date: Wed Jul 23 01:40:24 2008 Subject: [C2hs] available.h on Mac (bug #6) Message-ID: <9979e72e0807222250k3530a771sfb4163dffddefabf@mail.gmail.com> 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? Cheers, John Lato From duncan.coutts at worc.ox.ac.uk Wed Jul 23 07:07:13 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jul 23 06:55:55 2008 Subject: [C2hs] available.h on Mac (bug #6) In-Reply-To: <9979e72e0807222250k3530a771sfb4163dffddefabf@mail.gmail.com> References: <9979e72e0807222250k3530a771sfb4163dffddefabf@mail.gmail.com> Message-ID: <1216811233.12754.16.camel@localhost> 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 From jwlato at gmail.com Wed Jul 23 13:44:55 2008 From: jwlato at gmail.com (John Lato) Date: Wed Jul 23 13:34:55 2008 Subject: [C2hs] available.h on Mac (bug #6) In-Reply-To: <1216811233.12754.16.camel@localhost> References: <9979e72e0807222250k3530a771sfb4163dffddefabf@mail.gmail.com> <1216811233.12754.16.camel@localhost> Message-ID: <9979e72e0807231044o47a24564pe3786dc15d915524@mail.gmail.com> On Wed, Jul 23, 2008 at 6:07 AM, Duncan Coutts 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.