warning: format '%ld' expects argument of

2019-08-28 07:49发布

Wrt my this question,I am not able to cross check the output . I am getting some wrong print statement after execution .Can someone tell me whether printf() statements are wrong or logic that I am doing is wrong .

CODE:

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);

OUTPUT:

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

WARNING:

 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);
                            ^

Can somebody tell me How I can confirm the logic by using log/printf messages .

1条回答
爷、活的狠高调
2楼-- · 2019-08-28 08:33

You are using NEON extensions. They are not normal variables, as they are stored in NEON registers. You need to use special function to fetch data from them. For example, to read single-lined int64 value you need to call to vget_lane_s64. It will return normal 64-bit number which you can then fed to printf().

And yes, for 64-bit wide variables you need "%lld" format.

查看更多
登录 后发表回答