简体   繁体   English

以下代码中“'asm'中的不可能约束”错误的原因

[英]Reason for the “ impossible constraint in ‘asm” error in below code

Could anybody help me in identifying reason for the below compiler error. 任何人都可以帮助我确定以下编译器错误的原因。

" ..\\TestRT\\TDP\\PPCGNU\\lib\\custom.h:428: error: impossible constraint in 'asm' " .. \\ TestRT \\ TDP \\ PPCGNU \\ lib \\ custom.h:428:错误:'asm'中不可能的约束

Code: 码: 在此处输入图片说明

Thanks in advance! 提前致谢!

I think documentation answers this question. 我认为文档可以回答这个问题。 You probably have x86 code that you are building for x86-64. 您可能具有要为x86-64构建的x86代码。 A is valid for x86, but not for x86-64. A对x86有效,但对x86-64无效。 GCC documentation explains how to replace A by a for x86-64: GCC文档说明了如何用x86-64替换A:

"This is not correct on x86-64 as it would allocate tick in either ax or dx. You have to use the following variant instead:" “这在x86-64上是不正确的,因为它将在ax或dx中分配刻度。您必须使用以下变体:”

unsigned long long rdtsc (void)
{
  unsigned int tickl, tickh;
  __asm__ __volatile__("rdtsc":"=a"(tickl),"=d"(tickh));
  return ((unsigned long long)tickh << 32)|tickl;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM