[C2hs] BUG: string.h, (FC4 x86_64)

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Tue May 23 09:30:45 EDT 2006


On Tue, 2006-05-23 at 09:00 +0300, Ville Tirronen wrote:
> Hello,
> I think I've got a bug with c2hs 0.14.5. I have a program
> that compiles neatly on FC4 but fails when tried on x86_64 FC4.
> 
> c2hs fails on string.h. Attached are the string.h of the system and
> relevant .i file.
> 
> -----------
> 
> [aleator at thoth HopenCV]$ c2hs -k --cppopts='-I/usr/include/opencv'
> cvWrapLEO.h Image.chs
> c2hs: Error in C header file.
> 
> /usr/include/string.h:270: (column 99) [FATAL]
>   >>> Syntax error!
>   The symbol `__attribute__' does not fit here.

So the bug here is in parsing this bit:

extern int strerror_r (int __errnum, char *__buf, size_t __buflen)
__asm__ ("" "__xpg_strerror_r") __attribute__ ((__nothrow__))
__attribute__ ((__nonnull__ (2)));


In particular the current c2hs C parser only allows __asm__ decorations
after __attribute__ decorations, not mixed as in this example.

The reason it happened on one machine and not another might be to do
with this __REDIRECT_NTH define:

#  ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (strerror_r,
                           (int __errnum, char *__buf, size_t __buflen),
                           __xpg_strerror_r) __nonnull ((2));
#  else
extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
     __THROW __nonnull ((2));
#   define strerror_r __xpg_strerror_r
#  endif

Presumably on FC4 x86_64 it defines __REDIRECT_NTH and so gets the extra
asm bit.

We should try and find some clearer spec on the GNU C grammar. I was
working from a yacc parser in gcc 3.3.x when I added some support for
the __asm__ annotations.

Duncan



More information about the C2hs mailing list