I am using Qt and want to include the ttmath library. It tested fine on Windows XP and Windows 7. I use Qt-creator on Ubuntu now and when I try to compile the project it gives me following error:
.../ttmathuint_x86.h:637: error: inconsistent operand constraints in an 'asm'
: "cc", "memory" );
^
Part of the code looks like this:
#ifdef __GNUC__
uint dummy, dummy2;
__asm__ __volatile__(
"xorl %%edx, %%edx \n"
"negl %%eax \n" // CF=1 if rax!=0 , CF=0 if rax==0
"1: \n"
"movl (%%esi,%%edx,4), %%eax \n"
"sbbl %%eax, (%%ebx,%%edx,4) \n"
"incl %%edx \n"
"decl %%ecx \n"
"jnz 1b \n"
"adc %%ecx, %%ecx \n"
: "=c" (c), "=a" (dummy), "=d" (dummy2)
: "0" (b), "1" (c), "b" (p1), "S" (p2)
: "cc", "memory" );
#endif
The error only shows when I add parser to my project like one from the last example, here: http://www.ttmath.org/samples
I have no idea why that doesn't work since I know little about assembly or compilation process.
I read on the internet that the resolution is to add QMAKE_CXXFALGS = -fno-gcse in my ".pro" file but it didn't work.
The reason for this error is the
-fPICor-fpiccompiler flag which indicates that position independent code should be emitted. To locate variables it uses a global offset table whose pointer is stored inebx. Therefore with this flag you are not allowed to useebxin inline assembly.According to https://software.intel.com/en-us/blogs/2014/12/26/new-optimizations-for-x86-in-upcoming-gcc-50-32bit-pic-mode this is changed in GCC 5.0. The library probably changes your flags so you have to see if you can change your code.