'asm'中不一致的操作数约束
Inconsistent operand constraints in an 'asm'
我正在使用Qt,并希望包含ttmath库。它在Windows XP和Windows 7上测试良好。我现在在 Ubuntu 上使用 Qt-creator,当我尝试编译项目时,它给了我以下错误:
.../ttmathuint_x86.h:637: error: inconsistent operand constraints in an 'asm'
: "cc", "memory" );
^
部分代码如下所示:
#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
该错误仅在我将解析器添加到我的项目时显示,例如上一个示例中的解析器,如下所示:http://www.ttmath.org/samples
我不知道为什么这不起作用,因为我对汇编或编译过程知之甚少。
我在互联网上读到解决方案是在我的".pro"文件中添加QMAKE_CXXFALGS = -fno-gcse,但它不起作用。
此错误的原因是 -fPIC
或 -fpic
编译器标志,该标志指示应发出与位置无关的代码。为了定位变量,它使用全局偏移表,其指针存储在 ebx
中。因此,使用此标志,不允许在内联程序集中使用ebx
。
根据 https://software.intel.com/en-us/blogs/2014/12/26/new-optimizations-for-x86-in-upcoming-gcc-50-32bit-pic-mode,这在GCC 5.0中发生了变化。该库可能会更改您的标志,因此您必须查看是否可以更改代码。
就我而言,我可以解决它将我的 gcc 更新到 5.0 版
这是源链接 https://askubuntu.com/questions/618474/how-to-install-the-latest-gcurrently-5-1-in-ubuntucurrently-14-04,这些是他们建议的命令(以及我使用的命令):
sudo add-apt-repository ppa:ubuntu-toolchain-r/testsudo apt-get 更新sudo apt-get install gcc-5 g++-5
sudo update-alternatives
- 控制允许动态运行c++的并发操作数
- 函数作为模板参数,是否对返回类型强制约束
- 约束和显式模板实例化
- 为什么C++逐位AND运算符在不同大小的操作数中表现为这样
- IpOpt拒绝解决不受约束的问题
- 使用C++模板时表达约束
- 如何在 SCIP C++ 接口中获取 MILP 约束矩阵中的系数值
- 错误 C2679:二进制"<<":未找到采用类型 'std::string_view' 的右侧操作数的运算符(或者没有可接受的转换)
- C++ 带有向量的 IF 计算操作数
- 是否所有C++运算符都接受操作数?
- 一元*运算符的操作数是否期望一个 prvalue
- 与'operator='不匹配(操作数类型'String'且"void")
- 受约束的成员函数和显式模板实例化
- 不正确的操作数类型 MSVC
- C2678 二进制 '==':未找到采用 'Card' 类型左操作数的运算符(或者没有可接受的转换)
- 错误:类型"double()"和"double()"的操作数无效到二进制&quo
- 具有多种约束(例如重量、体积等)的背包
- 'asm'中不一致的操作数约束
- 错误:使用gcc 32位时,"asm"操作数具有不可能的约束
- 收到错误:将我的 c++ 代码从 Linux 移植到 android 时'asm'中的操作数约束不一致