c - 警告 : format '%ld' expects argument of type 'long int' , 但参数的类型为 '__builtin_neon_di'

标签 c simd neon cortex-a

我的this question ,我无法交叉检查输出。 我在执行后收到一些错误的打印语句。有人可以告诉我 printf() 语句是否错误,或者我正在执行的逻辑是否错误。

代码:

int64_t arr[2]  = {227802,9896688};
int64x2_t check64_2 = vld1q_s64(arr);

for(int i = 0;i < 2; i++){
    printf("check64_2[%d]: %ld\n",i,check64_2[i]);
}

int64_t way1   = check64_2[0] + check64_2[1];

int64x1_t way2 = vset_lane_s64(vgetq_lane_s64(check64_2, 0) + vgetq_lane_s64(check64_2, 1), way2, 0);

int64x1_t way3 = vadd_s64(vget_high_s64 (check64_2),vget_low_s64 (check64_2));

printf("way1 :%ld \n",way1);
printf("way2 :%ld \n",way2);
printf("way3 :%ld \n",way3);

输出:

check64_2[0]: 227802
check64_2[1]: 9896688
way1 :0 
way2 :0 
way3 :0 

警告:

 warning:format '%ld' expects argument of type 'long int', but argument 3 has type '__builtin_neon_di'printf("check64_2[%d]: %ld\n",i,check64_2[i]);
 warning:format '%ld' expects argument of type 'long int', but argument 2 has type 'int64_t {aka long long int}' [-Wformat=]
  printf("way1 :%ld \n",way1);
                            ^

有人可以告诉我如何使用 log/printf 消息确认逻辑。

最佳答案

您正在使用 NEON 扩展。它们不是普通变量,因为它们存储在 NEON 寄存器中。您需要使用特殊函数从它们中获取数据。例如,要读取单行 int64 值,您需要调用 vget_lane_s64。它将返回正常的 64 位数字,然后您可以将其提供给 printf()

是的,对于 64 位宽变量,您需要 "%lld" 格式。

关于c - 警告 : format '%ld' expects argument of type 'long int' , 但参数的类型为 '__builtin_neon_di',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30328555/

相关文章:

c - 可以用相同的数字进行可能的组合

java - 将数组/指针从 C 转换为 Java

c - AVR C 函数可以在 Main 中运行,但不能在其他函数中运行

c++ - 使用 AVX2 在程序集 x86_64 中添加两个 vector 加上技术说明

algorithm - 使用 SIMD 指令是否可以进行 3x3 矩阵求逆?

assembly - 如何将浮点常量移动到 FP 寄存器中?

c - pthread_join 似乎修改了我的循环索引

x86 - Rust 获取 SIMD 向量中真实字节的索引

c++ - 用于检查两个 double 值是否足够不同的 simd 代码

ios - RGBA 到 ABGR : Inline arm neon asm for iOS/Xcode