haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
199 stars 50 forks source link

GCC-7.0 specific _Float128 type - cannot recognize #198

Open XVilka opened 6 years ago

XVilka commented 6 years ago

When compiling alsa-mixer Haskell library met this problem:

Building alsa-mixer-0.2.0.3...
Preprocessing library alsa-mixer-0.2.0.3...
c2hs: C header contains errors:

/usr/include/bits/floatn.h:73: (column 29) [ERROR]  >>> Syntax error !
  The symbol `;' does not fit here.

Lines that cause it:

/* The remaining of this file provides support for older compilers.  */
#if __HAVE_FLOAT128

/* The type _Float128 exists only since GCC 7.0.  */
# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
typedef __float128 _Float128;
# endif

Attaching full header here floatn.h.zip

Gentoo bug https://bugs.gentoo.org/644200

abarbu commented 6 years ago

You can build by just skipping the header --cppopts=-D_BITS_FLOATN_H. At least there's a workaround since 6+ months later c2hs is still broken :(

krakrjak commented 6 years ago

This is the latest bug to show this error so I'm putting this here. (also mentioned in #192 and #191) I have pushed a commit with a potential fix in language_c. It could use some testing as I don't have as easy a way to replicate this as everyone else seems to.

Commit a7574997997752d98266d45c48ba21d801d8c77b at github/krakrjak/language-c is a straightforward diff, it builds here and needs some wider testing.

qrilka commented 5 years ago

I'm not sure why but switching to GCC 7 on Gentoo resolved this issue for me, like it's described in https://bugs.gentoo.org/644200

peterbecich commented 5 years ago

Thanks @qrilka . This worked for me: stack install alsa-mixer --with-gcc /usr/bin/gcc-7

XVilka commented 4 years ago

Was this fixed? Seems not reproducible anymore.

krakrjak commented 4 years ago

If you are using gcc-7 then this issue is 100% fixed. Potentially there is still an issue for pre-gcc-7 version (maybe), but we haven't seen reports of this issue when using gcc<7 in over a year.