Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clang and __float128 bug/error

Tags:

c++

llvm

clang

I've successfully compiled the current 3.3 branch of clang. But then C++ compilation of any file fails with the bug/error. Can that be fixed?

In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/iostream:39:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/ostream:39:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/ios:40:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/char_traits.h:40:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_algobase.h:65:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_pair.h:61:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/move.h:57:
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/type_traits:256:39: error: use of
      undeclared identifier '__float128'
    struct __is_floating_point_helper<__float128>
                                      ^
1 error generated.
like image 271
Cartesius00 Avatar asked Nov 23 '12 09:11

Cartesius00


4 Answers

You can fix it with:

CXXFLAGS+="-D__STRICT_ANSI__"
like image 145
Leonid Volnitsky Avatar answered Oct 20 '22 19:10

Leonid Volnitsky


I don't think clang supports __float128. It may be the same type as long double (which is 16 bytes in clang) so it may be a simple case of inserting:

#define __float128 long double

or:

typedef long double __float128;

somewhere early in your include chain.

I'm not guaranteeing that will work but it may, and it's probably best to try it out rather than wait until clang starts supporting more gcc extensions.

Either that, or switch to gcc, if that's an option. I'm pretty certain that gcc supports all of the gcc extensions :-)

like image 43
paxdiablo Avatar answered Oct 20 '22 17:10

paxdiablo


See http://llvm.org/bugs/show_bug.cgi?id=13530#c3 for possible workarounds.

like image 37
thakis Avatar answered Oct 20 '22 18:10

thakis


The solution is to have this declaration. It works like a charm:

#ifdef __clang__
typedef struct { long double x, y; } __float128;
#endif

Solutions with #define don't work because of the template specification redeclaration error.

Of course this is a hack, and you must be safe. I want clang just for a few experiments, so it won't cause any troubles.

like image 2
Cartesius00 Avatar answered Oct 20 '22 18:10

Cartesius00