作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我使用英特尔函数 _rdrand16_step()
编写了一段代码,在 Windows(Visual Studio 2017)上运行良好,但在 Linux(g++)上我无法使其运行。我在我的代码中调用了该函数 2 次:
#include <immintrin.h>
...
unsigned short val = 0;
if (_rdrand16_step(&val))
...
_rdrand16_step(&val);
...
g++ 输出如下:
/usr/lib/gcc/x86_64-linux-gnu/8/include/immintrin.h: In member function ‘int otp_s7c::crypt(std::__cxx11::string, std::__cxx11::string, long long unsigned int)’:
/usr/lib/gcc/x86_64-linux-gnu/8/include/immintrin.h:129:1: error: inlining failed in call to always_inline ‘int _rdrand16_step(short unsigned int*)’: target specific option mismatch
_rdrand16_step (unsigned short *__P)
^~~~~~~~~~~~~~
otp_s7c.cpp:139:24: note: called from here
if (_rdrand16_step(&val))
~~~~~~~~~~~~~~^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/8/include/immintrin.h:129:1: error: inlining failed in call to always_inline ‘int _rdrand16_step(short unsigned int*)’: target specific option mismatch
_rdrand16_step (unsigned short *__P)
^~~~~~~~~~~~~~
otp_s7c.cpp:148:23: note: called from here
_rdrand16_step(&val);
~~~~~~~~~~~~~~^~~~~~
最佳答案
这是一个有点误导性的错误消息,因为您实际上并没有告诉编译器您的目标体系结构支持 RDRAND 指令(据我所知,这里的重要部分是“目标特定选项”不匹配”部分在最后)。
将 -mrdrnd
添加到编译器标志似乎可以解决问题。
关于c++ - g++ 内联调用 always_inline "int _rdrand16_step()"失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52224421/
我在 WWDC 15 Fox 项目中发现了这行有趣的代码,文件 APPLCharacter.m。请告诉我类型,IDK much objective-c SCNAudioSource *_steps[S
如果您认为这是 2 年前提出的重复问题,我首先表示歉意。但我尝试了来自 stackoverflow 的各种答案或在 stackoverflow 之外用谷歌搜索,但它对我不起作用。 我的问题与现有问题几
我是一名优秀的程序员,十分优秀!