在尝试使用 rdrand 内在函数时,我遇到了以下烦恼。
使用我当前的编译器unsigned long
并且unsigned long long
都是 64 位的。但是, uint64_t 被定义为unsigned long
while_rdrand64_step
需要一个指向unsigned long long
.
在英特尔的网站上,该功能被定义为int _rdrand64_step (unsigned __int64* val)
. 我怎样才能以便携的方式处理这个问题?
#include <immintrin.h>
#include <stdint.h>
uint64_t example_rdrand64()
{
uint64_t n;
_rdrand64_step(&n);
return n;
}
铿锵 11.0 -march=ivybridge -O2
( https://godbolt.org/z/55sjsG ):
error: no matching function for call to '_rdrand64_step'
note: candidate function not viable: no known conversion
from 'unsigned int *' to 'unsigned long long *' for 1st argument
_rdrand64_step(unsigned long long *__p)