
Hi, I have a problem when processing "vte/vte.h" (from vte-0.11.10) with c2hs-0.12.0 and glibc-2.3.3: LANG=C c2hs --cppopts="-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include" vte.h Vte.chs c2hs: Generic fatal error. /usr/include/sys/sysmacros.h:43: (column 1) [FATAL]
Syntax error! The symbol `{' does not fit here.
It seems sys/sysmacros.h changed from glibc-2.3.2. Here is the context: # if defined __GNUC__ && __GNUC__ >= 2 __extension__ extern __inline unsigned int gnu_dev_major (unsigned long long int __dev) __THROW { return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); } Jens ps glibc-2.3.3 will be in Fedora Core 2, which is being released on Tuesday. pps I just uploaded c2hs-0.12.0 rpms built with glibc-2.3.3 to http://haskell.org/~petersen/rpms/c2hs/. I applied the following patch to build it with ghc-6.2.1: --- c2hs-0.12.0/c2hs/c/CAttrs.hs~ 2004-05-16 09:46:07.000000000 +0900 +++ c2hs-0.12.0/c2hs/c/CAttrs.hs 2004-05-16 09:46:07.000000000 +0900 @@ -144,7 +144,7 @@ -- leaveObjRangeC :: AttrC -> AttrC leaveObjRangeC ac = ac { - defObjsAC = fst . leaveRange . defObjsAC $ ac, + defObjsAC = fst . leaveRange . defObjsAC $ ac } -- add another definitions to the object name space (EXPORTED)

Hi Jens, On Sun, 2004-05-16 at 11:24, Jens Petersen wrote:
Hi,
I have a problem when processing "vte/vte.h" (from vte-0.11.10) with c2hs-0.12.0 and glibc-2.3.3:
LANG=C c2hs --cppopts="-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include" vte.h Vte.chs c2hs: Generic fatal error.
/usr/include/sys/sysmacros.h:43: (column 1) [FATAL]
Syntax error! The symbol `{' does not fit here.
It seems sys/sysmacros.h changed from glibc-2.3.2. Here is the context:
# if defined __GNUC__ && __GNUC__ >= 2 __extension__ extern __inline unsigned int gnu_dev_major (unsigned long long int __dev) __THROW { return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); }
The problem is the function body. C->Haskell's parser does not understand them (as they usually don't occur in header files). It is not hard to extend the parser to parse them and for c2hs to ignore them (after all C's statement syntax is quite simple and c2hs already handles expressions). I'll make this the next thing to add to c2hs (unless somebody beats me to it - it really is straight forward if you have got a C grammar at hand). It would be harder to find a way to actually use such functions from Haskell. gnu_dev_major is supposed to be inlined, which is hard to do in Haskell code.
Jens
ps glibc-2.3.3 will be in Fedora Core 2, which is being released on Tuesday.
pps I just uploaded c2hs-0.12.0 rpms built with glibc-2.3.3 to http://haskell.org/~petersen/rpms/c2hs/.
The web server claims I don't have permission to access this directory.
I applied the following patch to build it with ghc-6.2.1:
--- c2hs-0.12.0/c2hs/c/CAttrs.hs~ 2004-05-16 09:46:07.000000000 +0900 +++ c2hs-0.12.0/c2hs/c/CAttrs.hs 2004-05-16 09:46:07.000000000 +0900 @@ -144,7 +144,7 @@ -- leaveObjRangeC :: AttrC -> AttrC leaveObjRangeC ac = ac { - defObjsAC = fst . leaveRange . defObjsAC $ ac, + defObjsAC = fst . leaveRange . defObjsAC $ ac }
-- add another definitions to the object name space (EXPORTED)
Thanks, that's been included in the CVS version. Cheers, Manuel

On Sun, 2004-05-16 at 02:24, Jens Petersen wrote:
Hi,
I have a problem when processing "vte/vte.h" (from vte-0.11.10) with c2hs-0.12.0 and glibc-2.3.3:
/usr/include/sys/sysmacros.h:43: (column 1) [FATAL]
Syntax error! The symbol `{' does not fit here.
A temporary solution is to pass -C-D_SYS_SYSMACROS_H to c2hs so that cpp will not include the file and so c2hs will not see it. Another problem that I found when trying to run c2hs with vte/vte.h is that this header file contains an #ident directive. I've never seen this before, no other header files on my system have this. It seems to be used for rcs/cvs id info. The annoying thing is that cpp seems to pass it straight through and so c2hs chokes on it. Here's a patch to make c2hs ignore it. It's a diff from the gtk2hs fork so may not apply cleanly to Manuel's main branch but it's a fairly simple change. It follows what c2hs already does with #pragma directives. diff -C2 -r1.3 CLexer.hs *** c/CLexer.hs 3 Nov 2003 14:14:39 -0000 1.3 --- c/CLexer.hs 24 Jul 2004 20:25:52 -0000 *************** *** 46,50 **** -- `__const__', `__inline', `__inline__', `__restrict', and `__restrict__'. -- ! -- * Any line starting with `#pragma' is ignored. -- -- With K&R we refer to ``The C Programming Language'', second edition, Brain --- 46,50 ---- -- `__const__', `__inline', `__inline__', `__restrict', and `__restrict__'. -- ! -- * Any line starting with `#pragma' or '#ident' is ignored. -- -- With K&R we refer to ``The C Programming Language'', second edition, Brain *************** *** 444,447 **** --- 444,448 ---- >||< linedir >||< pragma + >||< rcsId -- whitespace (follows K&R A2.1) *************** *** 494,497 **** --- 495,511 ---- ppwhite = (char ' ' >|< char '\t')`star` epsilon + -- #ident directive + -- + -- * gcc's cpp seems to recognise this directive and it passes it through + -- to us. It seems to be used for cvs/rcs info. We simply ignore it (but + -- take care to update the position information) + -- + rcsId :: CLexer + rcsId = char '#' +> ppwhite +> string "ident" +> anyButNL`star` char '\n' + `lexmeta` \_ pos ns -> (Nothing, retPos pos, ns, Nothing) + where + ppwhite = (char ' ' >|< char '\t')`star` epsilon + + -- identifiers and keywords (follows K&R A2.3 and A2.4) -- Duncan
participants (3)
-
Duncan Coutts
-
Jens Petersen
-
Manuel M T Chakravarty