简体   繁体   中英

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' "

Code: 在此处输入图片说明

Thanks in advance!

I think documentation answers this question. You probably have x86 code that you are building for x86-64. A is valid for x86, but not for x86-64. GCC documentation explains how to replace A by a for x86-64:

"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:"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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