c - 对 `__lzcnt16 的 undefined reference ?

标签 c gcc sse undefined-reference intrinsics

我有这段代码,我正在尝试使用 -msse4.2(我试过 msse4)与 GCC-TDM 1.7.4-2 一起运行,但出现错误:

sse_lzcnt.c|7|warning: implicit declaration of function '__lzcnt16'|
sse_lzcnt.c|9|warning: too many arguments for format|
obj\Debug\sse_lzcnt.o||In function `main':|
sse_lzcnt.c|7|undefined reference to `__lzcnt16'|

undefined reference 通常是由于缺少 lib 文件(.a 结尾)导致的链接错误,但内在函数 header 不需要一个?

我确保内部函数 header 位于正确的包含目录中。这是代码,

#include <x86intrin.h>
#include <stdio.h>

int main()
{
        unsigned short __X  = 256;
        unsigned short RESULT = __lzcnt16(__X);

        printf("result: ", RESULT);

        return 0;
}

最佳答案

您需要使用 gcc 命令行选项:-mlzcnt

关于c - 对 `__lzcnt16 的 undefined reference ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17660044/

相关文章:

c++ - 使用 SIMD 优化列式最大值

c - 什么声明应该放在 C 头文件中?

c - 2 个警告 : 'int *' differs in levels of indirection from 'int **' and different types for formal and actual parameter 3

c - gcc-10.0.1 特定的段错误

c++ - 从 C 使用 C++ 共享库

对 if 语句使用多行宏时出现编译时错误

python - 如何写入 LLDB 中的 XMM 寄存器

c++ - 无法使用 gcc 构建 sigqueue 示例,但 g++ 可以吗?

c - 为什么这段修改字符串的代码不起作用?

c++ - 使用 SSE 加速浮点 5x5 矩阵 * vector 乘法