warning: format '%ld' expects argument of type 'long int', but argument has type '__builtin_neon_di'

丶灬走出姿态 提交于 2020-01-06 13:13:14

问题


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:


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.



来源:https://stackoverflow.com/questions/30328555/warning-format-ld-expects-argument-of-type-long-int-but-argument-has-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!