
I'm trying to use c2hs but get stuck when including sys/types.h (though the problem really resides in pthreadtypes.h): % ./Setup.hs build -v Preprocessing executables for kowasu-0.1... /usr/bin/c2hs -C -D__GLASGOW_HASKELL__=606 -C -Icsrc -o src/Kowasu/PTrace.hs src/Kowasu/PTrace.chs c2hs: Error in C header file. /usr/include/bits/pthreadtypes.h:69: (column 6) [FATAL]
Syntax error! The symbol `;' does not fit here.
The part of pthreadtypes.h where it chokes seems to be 65 __extension__ union 66 { 67 int __spins; 68 __pthread_slist_t __list; 69 }; 70 } __data; 71 char __size[__SIZEOF_PTHREAD_MUTEX_T]; 72 long int __align; 73 } pthread_mutex_t; Any pointers on how to solve this? (Besides manually resolving all defined types down to the C builtins.) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus.therning@gmail.com http://therning.org/magnus

magnus:
I'm trying to use c2hs but get stuck when including sys/types.h (though the problem really resides in pthreadtypes.h):
% ./Setup.hs build -v Preprocessing executables for kowasu-0.1... /usr/bin/c2hs -C -D__GLASGOW_HASKELL__=606 -C -Icsrc -o src/Kowasu/PTrace.hs src/Kowasu/PTrace.chs c2hs: Error in C header file.
/usr/include/bits/pthreadtypes.h:69: (column 6) [FATAL]
Syntax error! The symbol `;' does not fit here.
The part of pthreadtypes.h where it chokes seems to be
65 __extension__ union 66 { 67 int __spins; 68 __pthread_slist_t __list; 69 }; 70 } __data; 71 char __size[__SIZEOF_PTHREAD_MUTEX_T]; 72 long int __align; 73 } pthread_mutex_t;
Any pointers on how to solve this? (Besides manually resolving all defined types down to the C builtins.)
/M
Does it help to use the darcs version of c2hs? I've heard rumours that it can parse the linux kernel now.. -- Don

On Wed, 2007-03-14 at 09:56 +1100, Donald Bruce Stewart wrote:
magnus:
I'm trying to use c2hs but get stuck when including sys/types.h (though the problem really resides in pthreadtypes.h):
% ./Setup.hs build -v Preprocessing executables for kowasu-0.1... /usr/bin/c2hs -C -D__GLASGOW_HASKELL__=606 -C -Icsrc -o src/Kowasu/PTrace.hs src/Kowasu/PTrace.chs c2hs: Error in C header file.
/usr/include/bits/pthreadtypes.h:69: (column 6) [FATAL]
Syntax error! The symbol `;' does not fit here.
The part of pthreadtypes.h where it chokes seems to be
65 __extension__ union 66 { 67 int __spins; 68 __pthread_slist_t __list; 69 }; 70 } __data; 71 char __size[__SIZEOF_PTHREAD_MUTEX_T]; 72 long int __align; 73 } pthread_mutex_t;
Any pointers on how to solve this? (Besides manually resolving all defined types down to the C builtins.)
/M
Does it help to use the darcs version of c2hs? I've heard rumours that it can parse the linux kernel now..
Yes, I do have a C parser that can parse the linux kernel and that of course includes anonymous structs and unions. Currently I'm part way through merging these changes into the darcs version of c2hs. So, Magnus, you can wait 'til I finish merging my changes into c2hs or you can have a go yourself if you're desperate. I posted the full code recently: http://haskell.org/~duncan/c2hs/c2hs-newparser.tar.gz That's just a snapshot of my development tree, so don't expect it to work 'out of the box'. In particular the rest of c2hs doesn't understand the new extensions that the parser can now handle. Duncan

On Wed, Mar 14, 2007 at 12:27:10 +1100, Duncan Coutts wrote: [..]
Yes, I do have a C parser that can parse the linux kernel and that of course includes anonymous structs and unions. Currently I'm part way through merging these changes into the darcs version of c2hs.
Excellent news!
So, Magnus, you can wait 'til I finish merging my changes into c2hs or you can have a go yourself if you're desperate. I posted the full code recently:
I have a very dirty work-around at the moment so I'm not in a terrible hurry, but it'd be great to see a release of c2hs 0.14.6 soon-ish :-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus.therning@gmail.com http://therning.org/magnus

Magnus Therning wrote:
I'm trying to use c2hs but get stuck when including sys/types.h (though the problem really resides in pthreadtypes.h):
/usr/include/bits/pthreadtypes.h:69: (column 6) [FATAL]
Syntax error! The symbol `;' does not fit here.
65 __extension__ union 66 { 67 int __spins; 68 __pthread_slist_t __list; 69 }; 70 } __data; 71 char __size[__SIZEOF_PTHREAD_MUTEX_T]; 72 long int __align; 73 } pthread_mutex_t;
This is an unnamed union. It seems that most compilers these days support these, but it isn't officially allowed by the C language. Another post mentioned that development on c2hs might support this kind of construct. Dave
participants (4)
-
David Brown
-
dons@cse.unsw.edu.au
-
Duncan Coutts
-
Magnus Therning