“__rotatel4”的名称查找未找到声明

The name lookup for "__rotatel4" did not find a declaration

我正在编译农场的 GCC111 上工作。机器是 AIX 7.1,POWER7 和 IBM XLC 12.1。我正在尝试使用 __rotatel4:

$ cat test.cxx
#include <cstdlib>

unsigned int Foo (unsigned int x)
{
  return __rotatel4(x, 4U);
}

编译结果为:

$ xlC -O3 -c test.cxx
"test.cxx", line 5.10: 1540-0274 (S) The name lookup for "__rotatel4" did not find a declaration.

根据编译器手册IBM XL C/C++ for AIX, V12.1(第 486 页),内部函数应该可用。这是原型,它没有像 POWER6 这样的限制:

unsigned int __rotatel4 (unsigned int rs, unsigned int shift)

添加-qarch=pwr7 and/or -D_XOPEN_SOURCE=600 导致同样的错误。我找到了Unexpected name lookup error "1540-0274 (S)" when compiling code with templates,但是这里好像不适用

如何在程序中使用__rotatel4


gcc111$ oslevel -s
7100-03-02-1412

gcc111$ xlC -qversion
IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72)
Version: 12.01.0000.0000

对于 XL C/C++ V12.1,您需要包含 <builtins.h>:

$ cat aaa.cpp
#include <cstdlib>

unsigned int Foo (unsigned int x)
{
  return __rotatel4(x, 4U);
}
$ xlC aaa.cpp -c
"aaa.cpp", line 5.10: 1540-0274 (S) The name lookup for "__rotatel4" did not find a declaration.
$ cat aaa.cpp
#include <cstdlib>
#include <builtins.h>

unsigned int Foo (unsigned int x)
{
  return __rotatel4(x, 4U);
}
$ xlC aaa.cpp -c
$

对于即将发布的 16.1 版本(处于测试阶段),您不需要它。 (不管有没有它,它都可以工作。)